@pnpm/cli.default-reporter 1002.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +41 -0
  3. package/lib/constants.d.ts +1 -0
  4. package/lib/constants.js +4 -0
  5. package/lib/index.d.ts +54 -0
  6. package/lib/index.js +230 -0
  7. package/lib/mergeOutputs.d.ts +4 -0
  8. package/lib/mergeOutputs.js +69 -0
  9. package/lib/reportError.d.ts +3 -0
  10. package/lib/reportError.js +425 -0
  11. package/lib/reporterForClient/index.d.ts +52 -0
  12. package/lib/reporterForClient/index.js +94 -0
  13. package/lib/reporterForClient/outputConstants.d.ts +4 -0
  14. package/lib/reporterForClient/outputConstants.js +6 -0
  15. package/lib/reporterForClient/pkgsDiff.d.ts +36 -0
  16. package/lib/reporterForClient/pkgsDiff.js +113 -0
  17. package/lib/reporterForClient/reportBigTarballsProgress.d.ts +8 -0
  18. package/lib/reporterForClient/reportBigTarballsProgress.js +26 -0
  19. package/lib/reporterForClient/reportContext.d.ts +10 -0
  20. package/lib/reporterForClient/reportContext.js +34 -0
  21. package/lib/reporterForClient/reportDeprecations.d.ts +11 -0
  22. package/lib/reporterForClient/reportDeprecations.js +27 -0
  23. package/lib/reporterForClient/reportExecutionTime.d.ts +6 -0
  24. package/lib/reporterForClient/reportExecutionTime.js +13 -0
  25. package/lib/reporterForClient/reportHooks.d.ts +8 -0
  26. package/lib/reporterForClient/reportHooks.js +12 -0
  27. package/lib/reporterForClient/reportIgnoredBuilds.d.ts +11 -0
  28. package/lib/reporterForClient/reportIgnoredBuilds.js +21 -0
  29. package/lib/reporterForClient/reportInstallChecks.d.ts +7 -0
  30. package/lib/reporterForClient/reportInstallChecks.js +19 -0
  31. package/lib/reporterForClient/reportInstallingConfigDeps.d.ts +5 -0
  32. package/lib/reporterForClient/reportInstallingConfigDeps.js +18 -0
  33. package/lib/reporterForClient/reportLifecycleScripts.d.ts +13 -0
  34. package/lib/reporterForClient/reportLifecycleScripts.js +193 -0
  35. package/lib/reporterForClient/reportMisc.d.ts +17 -0
  36. package/lib/reporterForClient/reportMisc.js +69 -0
  37. package/lib/reporterForClient/reportPeerDependencyIssues.d.ts +7 -0
  38. package/lib/reporterForClient/reportPeerDependencyIssues.js +16 -0
  39. package/lib/reporterForClient/reportProgress.d.ts +16 -0
  40. package/lib/reporterForClient/reportProgress.js +123 -0
  41. package/lib/reporterForClient/reportRequestRetry.d.ts +5 -0
  42. package/lib/reporterForClient/reportRequestRetry.js +15 -0
  43. package/lib/reporterForClient/reportScope.d.ts +8 -0
  44. package/lib/reporterForClient/reportScope.js +41 -0
  45. package/lib/reporterForClient/reportSkippedOptionalDependencies.d.ts +7 -0
  46. package/lib/reporterForClient/reportSkippedOptionalDependencies.js +8 -0
  47. package/lib/reporterForClient/reportStats.d.ts +13 -0
  48. package/lib/reporterForClient/reportStats.js +143 -0
  49. package/lib/reporterForClient/reportSummary.d.ts +19 -0
  50. package/lib/reporterForClient/reportSummary.js +79 -0
  51. package/lib/reporterForClient/reportUpdateCheck.d.ts +8 -0
  52. package/lib/reporterForClient/reportUpdateCheck.js +42 -0
  53. package/lib/reporterForClient/utils/formatPrefix.d.ts +2 -0
  54. package/lib/reporterForClient/utils/formatPrefix.js +19 -0
  55. package/lib/reporterForClient/utils/formatWarn.d.ts +1 -0
  56. package/lib/reporterForClient/utils/formatWarn.js +8 -0
  57. package/lib/reporterForClient/utils/zooming.d.ts +4 -0
  58. package/lib/reporterForClient/utils/zooming.js +13 -0
  59. package/package.json +76 -0
@@ -0,0 +1,425 @@
1
+ import { renderDedupeCheckIssues } from '@pnpm/installing.dedupe.issues-renderer';
2
+ import { renderPeerIssues } from '@pnpm/installing.render-peer-issues';
3
+ import chalk from 'chalk';
4
+ import { equals } from 'ramda';
5
+ import StackTracey from 'stacktracey';
6
+ import { EOL } from './constants.js';
7
+ StackTracey.maxColumnWidths = {
8
+ callee: 25,
9
+ file: 350,
10
+ sourceLine: 25,
11
+ };
12
+ const highlight = chalk.yellow;
13
+ const colorPath = chalk.gray;
14
+ export function reportError(logObj, config) {
15
+ const errorInfo = getErrorInfo(logObj, config);
16
+ if (!errorInfo)
17
+ return null;
18
+ let output = formatErrorSummary(errorInfo.title, logObj.err?.code);
19
+ if (logObj.pkgsStack != null) {
20
+ if (logObj.pkgsStack.length > 0) {
21
+ output += `\n\n${formatPkgsStack(logObj.pkgsStack)}`;
22
+ }
23
+ else if ('prefix' in logObj && logObj.prefix) {
24
+ output += `\n\nThis error happened while installing a direct dependency of ${logObj.prefix}`;
25
+ }
26
+ }
27
+ if (errorInfo.body) {
28
+ output += `\n\n${errorInfo.body}`;
29
+ }
30
+ return output;
31
+ }
32
+ function getErrorInfo(logObj, config) {
33
+ if ('err' in logObj && logObj.err) {
34
+ const err = logObj.err;
35
+ switch (err.code) {
36
+ case 'ERR_PNPM_UNEXPECTED_STORE':
37
+ return reportUnexpectedStore(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
38
+ case 'ERR_PNPM_UNEXPECTED_VIRTUAL_STORE':
39
+ return reportUnexpectedVirtualStoreDir(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
40
+ case 'ERR_PNPM_STORE_BREAKING_CHANGE':
41
+ return reportStoreBreakingChange(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
42
+ case 'ERR_PNPM_MODULES_BREAKING_CHANGE':
43
+ return reportModulesBreakingChange(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
44
+ case 'ERR_PNPM_MODIFIED_DEPENDENCY':
45
+ return reportModifiedDependency(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
46
+ case 'ERR_PNPM_LOCKFILE_BREAKING_CHANGE':
47
+ return reportLockfileBreakingChange(err, logObj);
48
+ case 'ERR_PNPM_RECURSIVE_RUN_NO_SCRIPT':
49
+ return { title: err.message };
50
+ case 'ERR_PNPM_MISSING_TIME':
51
+ return { title: err.message, body: 'If you cannot fix this registry issue, then set "resolution-mode" to "highest".' };
52
+ case 'ERR_PNPM_NO_MATCHING_VERSION':
53
+ case 'ERR_PNPM_NO_MATURE_MATCHING_VERSION':
54
+ return formatNoMatchingVersion(err, logObj);
55
+ case 'ERR_PNPM_RECURSIVE_FAIL':
56
+ return formatRecursiveCommandSummary(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
57
+ case 'ERR_PNPM_BAD_TARBALL_SIZE':
58
+ return reportBadTarballSize(err, logObj);
59
+ case 'ELIFECYCLE':
60
+ return reportLifecycleError(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
61
+ case 'ERR_PNPM_UNSUPPORTED_ENGINE':
62
+ return reportEngineError(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
63
+ case 'ERR_PNPM_PEER_DEP_ISSUES':
64
+ return reportPeerDependencyIssuesError(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
65
+ case 'ERR_PNPM_DEDUPE_CHECK_ISSUES':
66
+ return reportDedupeCheckIssuesError(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
67
+ case 'ERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER':
68
+ return reportSpecNotSupportedByAnyResolverError(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
69
+ case 'ERR_PNPM_FETCH_401':
70
+ case 'ERR_PNPM_FETCH_403':
71
+ return reportAuthError(err, logObj, config); // eslint-disable-line @typescript-eslint/no-explicit-any
72
+ default: {
73
+ // Errors with unknown error codes are printed with stack trace
74
+ if (!err.code?.startsWith?.('ERR_PNPM_')) {
75
+ return formatGenericError(err.message ?? logObj.message, err.stack);
76
+ }
77
+ return {
78
+ title: err.message ?? '',
79
+ body: logObj.hint,
80
+ };
81
+ }
82
+ }
83
+ }
84
+ return { title: logObj.message };
85
+ }
86
+ function formatPkgNameVer({ name, version }) {
87
+ return version == null
88
+ ? name
89
+ : `${name}@${version}`;
90
+ }
91
+ function formatPkgsStack(pkgsStack) {
92
+ return `This error happened while installing the dependencies of \
93
+ ${formatPkgNameVer(pkgsStack[0])}\
94
+ ${pkgsStack.slice(1).map((pkgInfo) => `${EOL} at ${formatPkgNameVer(pkgInfo)}`).join('')}`;
95
+ }
96
+ function formatNoMatchingVersion(err, msg) {
97
+ const meta = msg.packageMeta;
98
+ const latestVersion = meta['dist-tags'].latest;
99
+ let output = `The latest release of ${meta.name} is "${latestVersion}".`;
100
+ const latestTime = msg.packageMeta.time?.[latestVersion];
101
+ if (latestTime) {
102
+ output += ` Published at ${stringifyDate(latestTime)}`;
103
+ }
104
+ output += EOL;
105
+ if (!equals(Object.keys(meta['dist-tags']), ['latest'])) {
106
+ output += EOL + 'Other releases are:' + EOL;
107
+ for (const tag in meta['dist-tags']) {
108
+ if (tag !== 'latest') {
109
+ const version = meta['dist-tags'][tag];
110
+ output += ` * ${tag}: ${version}`;
111
+ const time = msg.packageMeta.time?.[version];
112
+ if (time) {
113
+ output += ` published at ${stringifyDate(time)}`;
114
+ }
115
+ output += EOL;
116
+ }
117
+ }
118
+ }
119
+ output += `${EOL}If you need the full list of all ${Object.keys(meta.versions).length} published versions run "pnpm view ${meta.name} versions".`;
120
+ if (msg.immatureVersion) {
121
+ output += `${EOL}${EOL}If you want to install the matched version ignoring the time it was published, you can add the package name to the minimumReleaseAgeExclude setting. Read more about it: https://pnpm.io/settings#minimumreleaseageexclude`;
122
+ }
123
+ return {
124
+ title: err.message,
125
+ body: output,
126
+ };
127
+ }
128
+ function stringifyDate(dateStr) {
129
+ const now = Date.now();
130
+ const oneDayAgo = now - 24 * 60 * 60 * 1000;
131
+ const date = new Date(dateStr);
132
+ if (date.getTime() < oneDayAgo) {
133
+ return date.toLocaleDateString();
134
+ }
135
+ return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
136
+ }
137
+ function reportUnexpectedStore(err, msg) {
138
+ return {
139
+ title: err.message,
140
+ body: `The dependencies at "${msg.modulesDir}" are currently linked from the store at "${msg.expectedStorePath}".
141
+
142
+ pnpm now wants to use the store at "${msg.actualStorePath}" to link dependencies.
143
+
144
+ If you want to use the new store location, reinstall your dependencies with "pnpm install".
145
+
146
+ You may change the global store location by running "pnpm config set store-dir <dir> --global".
147
+ (This error may happen if the node_modules was installed with a different major version of pnpm)`,
148
+ };
149
+ }
150
+ function reportUnexpectedVirtualStoreDir(err, msg) {
151
+ return {
152
+ title: err.message,
153
+ body: `The dependencies at "${msg.modulesDir}" are currently symlinked from the virtual store directory at "${msg.expected}".
154
+
155
+ pnpm now wants to use the virtual store at "${msg.actual}" to link dependencies from the store.
156
+
157
+ If you want to use the new virtual store location, reinstall your dependencies with "pnpm install".
158
+
159
+ You may change the virtual store location by changing the value of the virtual-store-dir config.`,
160
+ };
161
+ }
162
+ function reportStoreBreakingChange(msg) {
163
+ let output = `Store path: ${colorPath(msg.storePath)}
164
+
165
+ Run "pnpm install" to recreate node_modules.`;
166
+ if (msg.additionalInformation) {
167
+ output = `${output}${EOL}${EOL}${msg.additionalInformation}`;
168
+ }
169
+ output += formatRelatedSources(msg);
170
+ return {
171
+ title: 'The store used for the current node_modules is incompatible with the current version of pnpm',
172
+ body: output,
173
+ };
174
+ }
175
+ function reportModulesBreakingChange(msg) {
176
+ let output = `node_modules path: ${colorPath(msg.modulesPath)}
177
+
178
+ Run ${highlight('pnpm install')} to recreate node_modules.`;
179
+ if (msg.additionalInformation) {
180
+ output = `${output}${EOL}${EOL}${msg.additionalInformation}`;
181
+ }
182
+ output += formatRelatedSources(msg);
183
+ return {
184
+ title: 'The current version of pnpm is not compatible with the available node_modules structure',
185
+ body: output,
186
+ };
187
+ }
188
+ function formatRelatedSources(msg) {
189
+ let output = '';
190
+ if (!msg.relatedIssue && !msg.relatedPR)
191
+ return output;
192
+ output += EOL;
193
+ if (msg.relatedIssue) {
194
+ output += EOL + `Related issue: ${colorPath(`https://github.com/pnpm/pnpm/issues/${msg.relatedIssue}`)}`;
195
+ }
196
+ if (msg.relatedPR) {
197
+ output += EOL + `Related PR: ${colorPath(`https://github.com/pnpm/pnpm/pull/${msg.relatedPR}`)}`;
198
+ }
199
+ return output;
200
+ }
201
+ function formatGenericError(errorMessage, stack) {
202
+ if (stack) {
203
+ let prettyStack;
204
+ try {
205
+ prettyStack = new StackTracey(stack).asTable();
206
+ }
207
+ catch {
208
+ prettyStack = stack.toString();
209
+ }
210
+ if (prettyStack) {
211
+ return {
212
+ title: errorMessage,
213
+ body: prettyStack,
214
+ };
215
+ }
216
+ }
217
+ return { title: errorMessage };
218
+ }
219
+ function formatErrorSummary(message, code) {
220
+ return `${chalk.bgRed.black(`\u2009${code ?? 'ERROR'}\u2009`)} ${chalk.red(message)}`;
221
+ }
222
+ function reportModifiedDependency(msg) {
223
+ return {
224
+ title: 'Packages in the store have been mutated',
225
+ body: `These packages are modified:
226
+ ${msg.modified.map((pkgPath) => colorPath(pkgPath)).join(EOL)}
227
+
228
+ You can run ${highlight('pnpm install --force')} to refetch the modified packages`,
229
+ };
230
+ }
231
+ function reportLockfileBreakingChange(err, _msg) {
232
+ return {
233
+ title: err.message,
234
+ body: `Run with the ${highlight('--force')} parameter to recreate the lockfile.`,
235
+ };
236
+ }
237
+ function formatRecursiveCommandSummary(msg) {
238
+ const output = EOL + `Summary: ${chalk.red(`${msg.failures.length} fails`)}, ${msg.passes} passes` + EOL + EOL +
239
+ msg.failures.map(({ message, prefix }) => {
240
+ return prefix + ':' + EOL + formatErrorSummary(message);
241
+ }).join(EOL + EOL);
242
+ return {
243
+ title: '',
244
+ body: output,
245
+ };
246
+ }
247
+ function reportBadTarballSize(err, _msg) {
248
+ return {
249
+ title: err.message,
250
+ body: `Seems like you have internet connection issues.
251
+ Try running the same command again.
252
+ If that doesn't help, try one of the following:
253
+
254
+ - Set a bigger value for the \`fetch-retries\` config.
255
+ To check the current value of \`fetch-retries\`, run \`pnpm get fetch-retries\`.
256
+ To set a new value, run \`pnpm set fetch-retries <number>\`.
257
+
258
+ - Set \`network-concurrency\` to 1.
259
+ This change will slow down installation times, so it is recommended to
260
+ delete the config once the internet connection is good again: \`pnpm config delete network-concurrency\`
261
+
262
+ NOTE: You may also override configs via flags.
263
+ For instance, \`pnpm install --fetch-retries 5 --network-concurrency 1\``,
264
+ };
265
+ }
266
+ function reportLifecycleError(msg) {
267
+ if (msg.stage === 'test') {
268
+ return { title: 'Test failed. See above for more details.' };
269
+ }
270
+ if (typeof msg.errno === 'number') {
271
+ return { title: `Command failed with exit code ${msg.errno}.` };
272
+ }
273
+ return { title: 'Command failed.' };
274
+ }
275
+ function reportEngineError(msg) {
276
+ let output = '';
277
+ if (msg.wanted.pnpm) {
278
+ output += `\
279
+ Your pnpm version is incompatible with "${msg.packageId}".
280
+
281
+ Expected version: ${msg.wanted.pnpm}
282
+ Got: ${msg.current.pnpm}
283
+
284
+ This is happening because the package's manifest has an engines.pnpm field specified.
285
+ To fix this issue, install the required pnpm version globally.
286
+
287
+ To install the latest version of pnpm, run "pnpm i -g pnpm".
288
+ To check your pnpm version, run "pnpm -v".`;
289
+ }
290
+ if (msg.wanted.node) {
291
+ if (output)
292
+ output += EOL + EOL;
293
+ output += `\
294
+ Your Node version is incompatible with "${msg.packageId}".
295
+
296
+ Expected version: ${msg.wanted.node}
297
+ Got: ${msg.current.node}
298
+
299
+ This is happening because the package's manifest has an engines.node field specified.
300
+ To fix this issue, install the required Node version.`;
301
+ }
302
+ return {
303
+ title: 'Unsupported environment (bad pnpm and/or Node.js version)',
304
+ body: output,
305
+ };
306
+ }
307
+ function reportAuthError(err, msg, config) {
308
+ const foundSettings = [];
309
+ for (const [key, value] of Object.entries(config?.rawConfig ?? {})) {
310
+ if (key[0] === '@') {
311
+ foundSettings.push(`${key}=${String(value)}`);
312
+ continue;
313
+ }
314
+ if (key.endsWith('_auth') ||
315
+ key.endsWith('_authToken') ||
316
+ key.endsWith('username') ||
317
+ key.endsWith('_password')) {
318
+ foundSettings.push(`${key}=${hideSecureInfo(key, value)}`);
319
+ }
320
+ }
321
+ let output = msg.hint ? `${msg.hint}${EOL}${EOL}` : '';
322
+ if (foundSettings.length === 0) {
323
+ output += `No authorization settings were found in the configs.
324
+ Try to log in to the registry by running "pnpm login"
325
+ or add the auth tokens manually to the ~/.npmrc file.`;
326
+ }
327
+ else {
328
+ output += `These authorization settings were found:
329
+ ${foundSettings.join('\n')}`;
330
+ }
331
+ return {
332
+ title: err.message,
333
+ body: output,
334
+ };
335
+ }
336
+ function hideSecureInfo(key, value) {
337
+ if (key.endsWith('_password'))
338
+ return '[hidden]';
339
+ if (key.endsWith('_auth') || key.endsWith('_authToken'))
340
+ return `${value.substring(0, 4)}[hidden]`;
341
+ return value;
342
+ }
343
+ function reportPeerDependencyIssuesError(err, msg) {
344
+ const hasMissingPeers = getHasMissingPeers(msg.issuesByProjects);
345
+ const hints = [];
346
+ if (hasMissingPeers) {
347
+ hints.push(`To auto-install peer dependencies, add the following to "pnpm-workspace.yaml" in your project root:
348
+
349
+ autoInstallPeers: true`);
350
+ }
351
+ hints.push(`To disable failing on peer dependency issues, add the following to pnpm-workspace.yaml in your project root:
352
+
353
+ strictPeerDependencies: false
354
+ `);
355
+ const rendered = renderPeerIssues(msg.issuesByProjects);
356
+ if (!rendered) {
357
+ // This should never happen.
358
+ return {
359
+ title: err.message,
360
+ };
361
+ }
362
+ return {
363
+ title: err.message,
364
+ body: `${rendered}
365
+ ${hints.map((hint) => `hint: ${hint}`).join('\n')}
366
+ `,
367
+ };
368
+ }
369
+ function getHasMissingPeers(issuesByProjects) {
370
+ return Object.values(issuesByProjects)
371
+ .some((issues) => Object.values(issues.missing).flat().some(({ optional }) => !optional));
372
+ }
373
+ function reportDedupeCheckIssuesError(err, msg) {
374
+ return {
375
+ title: err.message,
376
+ body: `\
377
+ ${renderDedupeCheckIssues(msg.dedupeCheckIssues)}
378
+ Run ${chalk.yellow('pnpm dedupe')} to apply the changes above.
379
+ `,
380
+ };
381
+ }
382
+ function reportSpecNotSupportedByAnyResolverError(err, logObj) {
383
+ // If the catalog protocol specifier was sent to a "real resolver", it'll
384
+ // eventually throw a "specifier not supported" error since the catalog
385
+ // protocol is meant to be replaced before it's passed to any of the real
386
+ // resolvers.
387
+ //
388
+ // If this kind of error is thrown, and the dependency bareSpecifier is using the
389
+ // catalog protocol it's most likely because we're trying to install an out of
390
+ // repo dependency that was published incorrectly. For example, it may be been
391
+ // mistakenly published with 'npm publish' instead of 'pnpm publish'. Report a
392
+ // more clear error in this case.
393
+ if (logObj.package?.bareSpecifier?.startsWith('catalog:')) {
394
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
395
+ return reportExternalCatalogProtocolError(err, logObj);
396
+ }
397
+ return {
398
+ title: err.message ?? '',
399
+ body: logObj.hint,
400
+ };
401
+ }
402
+ function reportExternalCatalogProtocolError(err, logObj) {
403
+ const { pkgsStack } = logObj;
404
+ const problemDep = pkgsStack?.[0];
405
+ let body = `\
406
+ An external package outside of the pnpm workspace declared a dependency using
407
+ the catalog protocol. This is likely a bug in that external package. Only
408
+ packages within the pnpm workspace may use catalogs. Usages of the catalog
409
+ protocol are replaced with real specifiers on 'pnpm publish'.
410
+ `;
411
+ if (problemDep != null) {
412
+ body += `\
413
+
414
+ This is likely a bug in the publishing automation of this package. Consider filing
415
+ a bug with the authors of:
416
+
417
+ ${highlight(formatPkgNameVer(problemDep))}
418
+ `;
419
+ }
420
+ return {
421
+ title: err.message,
422
+ body,
423
+ };
424
+ }
425
+ //# sourceMappingURL=reportError.js.map
@@ -0,0 +1,52 @@
1
+ import type { Config } from '@pnpm/config.reader';
2
+ import type * as logs from '@pnpm/core-loggers';
3
+ import type { LogLevel } from '@pnpm/logger';
4
+ import type * as Rx from 'rxjs';
5
+ import { type FilterPkgsDiff } from './reportSummary.js';
6
+ export declare function reporterForClient(log$: {
7
+ context: Rx.Observable<logs.ContextLog>;
8
+ fetchingProgress: Rx.Observable<logs.FetchingProgressLog>;
9
+ executionTime: Rx.Observable<logs.ExecutionTimeLog>;
10
+ ignoredScripts: Rx.Observable<logs.IgnoredScriptsLog>;
11
+ progress: Rx.Observable<logs.ProgressLog>;
12
+ stage: Rx.Observable<logs.StageLog>;
13
+ deprecation: Rx.Observable<logs.DeprecationLog>;
14
+ summary: Rx.Observable<logs.SummaryLog>;
15
+ lifecycle: Rx.Observable<logs.LifecycleLog>;
16
+ stats: Rx.Observable<logs.StatsLog>;
17
+ installCheck: Rx.Observable<logs.InstallCheckLog>;
18
+ installingConfigDeps: Rx.Observable<logs.InstallingConfigDepsLog>;
19
+ registry: Rx.Observable<logs.RegistryLog>;
20
+ root: Rx.Observable<logs.RootLog>;
21
+ packageManifest: Rx.Observable<logs.PackageManifestLog>;
22
+ peerDependencyIssues: Rx.Observable<logs.PeerDependencyIssuesLog>;
23
+ requestRetry: Rx.Observable<logs.RequestRetryLog>;
24
+ link: Rx.Observable<logs.LinkLog>;
25
+ other: Rx.Observable<logs.Log>;
26
+ hook: Rx.Observable<logs.HookLog>;
27
+ scope: Rx.Observable<logs.ScopeLog>;
28
+ skippedOptionalDependency: Rx.Observable<logs.SkippedOptionalDependencyLog>;
29
+ packageImportMethod: Rx.Observable<logs.PackageImportMethodLog>;
30
+ updateCheck: Rx.Observable<logs.UpdateCheckLog>;
31
+ }, opts: {
32
+ appendOnly?: boolean;
33
+ cmd: string;
34
+ config?: Config;
35
+ env: NodeJS.ProcessEnv;
36
+ filterPkgsDiff?: FilterPkgsDiff;
37
+ process: NodeJS.Process;
38
+ isRecursive: boolean;
39
+ logLevel?: LogLevel;
40
+ pnpmConfig?: Config;
41
+ streamLifecycleOutput?: boolean;
42
+ aggregateOutput?: boolean;
43
+ throttleProgress?: number;
44
+ width?: number;
45
+ hideAddedPkgsProgress?: boolean;
46
+ hideProgressPrefix?: boolean;
47
+ hideLifecycleOutput?: boolean;
48
+ hideLifecyclePrefix?: boolean;
49
+ approveBuildsInstructionText?: string;
50
+ }): Array<Rx.Observable<Rx.Observable<{
51
+ msg: string;
52
+ }>>>;
@@ -0,0 +1,94 @@
1
+ import { throttleTime } from 'rxjs/operators';
2
+ import { reportBigTarballProgress } from './reportBigTarballsProgress.js';
3
+ import { reportContext } from './reportContext.js';
4
+ import { reportDeprecations } from './reportDeprecations.js';
5
+ import { reportExecutionTime } from './reportExecutionTime.js';
6
+ import { reportHooks } from './reportHooks.js';
7
+ import { reportIgnoredBuilds } from './reportIgnoredBuilds.js';
8
+ import { reportInstallChecks } from './reportInstallChecks.js';
9
+ import { reportInstallingConfigDeps } from './reportInstallingConfigDeps.js';
10
+ import { reportLifecycleScripts } from './reportLifecycleScripts.js';
11
+ import { LOG_LEVEL_NUMBER, reportMisc } from './reportMisc.js';
12
+ import { reportPeerDependencyIssues } from './reportPeerDependencyIssues.js';
13
+ import { reportProgress } from './reportProgress.js';
14
+ import { reportRequestRetry } from './reportRequestRetry.js';
15
+ import { reportScope } from './reportScope.js';
16
+ import { reportSkippedOptionalDependencies } from './reportSkippedOptionalDependencies.js';
17
+ import { reportStats } from './reportStats.js';
18
+ import { reportSummary } from './reportSummary.js';
19
+ import { reportUpdateCheck } from './reportUpdateCheck.js';
20
+ const PRINT_EXECUTION_TIME_IN_COMMANDS = {
21
+ install: true,
22
+ update: true,
23
+ add: true,
24
+ remove: true,
25
+ };
26
+ export function reporterForClient(log$, opts) {
27
+ const width = opts.width ?? process.stdout.columns ?? 80;
28
+ const cwd = opts.pnpmConfig?.dir ?? process.cwd();
29
+ const throttle = typeof opts.throttleProgress === 'number' && opts.throttleProgress > 0
30
+ ? throttleTime(opts.throttleProgress, undefined, { leading: true, trailing: true })
31
+ : undefined;
32
+ const outputs = [
33
+ reportMisc(log$, {
34
+ appendOnly: opts.appendOnly === true,
35
+ config: opts.config,
36
+ cwd,
37
+ logLevel: opts.logLevel,
38
+ zoomOutCurrent: opts.isRecursive,
39
+ }),
40
+ ];
41
+ // logLevelNumber: 0123 = error warn info debug
42
+ const logLevelNumber = LOG_LEVEL_NUMBER[opts.logLevel ?? 'info'] ?? LOG_LEVEL_NUMBER['info'];
43
+ const showInfo = logLevelNumber >= LOG_LEVEL_NUMBER.info;
44
+ if (logLevelNumber >= LOG_LEVEL_NUMBER.warn) {
45
+ outputs.push(reportPeerDependencyIssues(log$), reportDeprecations({
46
+ deprecation: log$.deprecation,
47
+ stage: log$.stage,
48
+ }, { cwd, isRecursive: opts.isRecursive }), reportRequestRetry(log$.requestRetry));
49
+ }
50
+ if (showInfo) {
51
+ if (opts.cmd in PRINT_EXECUTION_TIME_IN_COMMANDS) {
52
+ outputs.push(reportExecutionTime(log$.executionTime));
53
+ }
54
+ if (opts.cmd !== 'dlx') {
55
+ outputs.push(reportContext(log$, { cwd }));
56
+ }
57
+ outputs.push(reportLifecycleScripts(log$, {
58
+ appendOnly: (opts.appendOnly === true || opts.streamLifecycleOutput) && !opts.hideLifecycleOutput,
59
+ aggregateOutput: opts.aggregateOutput,
60
+ hideLifecyclePrefix: opts.hideLifecyclePrefix,
61
+ cwd,
62
+ width,
63
+ }), reportInstallChecks(log$.installCheck, { cwd }), reportInstallingConfigDeps(log$.installingConfigDeps), reportScope(log$.scope, { isRecursive: opts.isRecursive, cmd: opts.cmd }), reportSkippedOptionalDependencies(log$.skippedOptionalDependency, { cwd }), reportHooks(log$.hook, { cwd, isRecursive: opts.isRecursive }), reportUpdateCheck(log$.updateCheck, opts), reportProgress(log$, {
64
+ cwd,
65
+ throttle,
66
+ hideAddedPkgsProgress: opts.hideAddedPkgsProgress,
67
+ hideProgressPrefix: opts.hideProgressPrefix,
68
+ }), ...reportStats(log$, {
69
+ cmd: opts.cmd,
70
+ cwd,
71
+ isRecursive: opts.isRecursive,
72
+ width,
73
+ hideProgressPrefix: opts.hideProgressPrefix,
74
+ }));
75
+ if (!opts.appendOnly) {
76
+ outputs.push(reportBigTarballProgress(log$));
77
+ }
78
+ if (!opts.isRecursive) {
79
+ outputs.push(reportSummary(log$, {
80
+ cmd: opts.cmd,
81
+ cwd,
82
+ env: opts.env,
83
+ filterPkgsDiff: opts.filterPkgsDiff,
84
+ pnpmConfig: opts.pnpmConfig,
85
+ }));
86
+ }
87
+ outputs.push(reportIgnoredBuilds(log$, {
88
+ pnpmConfig: opts.pnpmConfig,
89
+ approveBuildsInstructionText: opts.approveBuildsInstructionText,
90
+ }));
91
+ }
92
+ return outputs;
93
+ }
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ export declare const PREFIX_MAX_LENGTH = 40;
2
+ export declare const hlValue: import("chalk").ChalkInstance;
3
+ export declare const ADDED_CHAR: string;
4
+ export declare const REMOVED_CHAR: string;
@@ -0,0 +1,6 @@
1
+ import chalk from 'chalk';
2
+ export const PREFIX_MAX_LENGTH = 40;
3
+ export const hlValue = chalk.cyanBright;
4
+ export const ADDED_CHAR = chalk.green('+');
5
+ export const REMOVED_CHAR = chalk.red('-');
6
+ //# sourceMappingURL=outputConstants.js.map
@@ -0,0 +1,36 @@
1
+ import type * as logs from '@pnpm/core-loggers';
2
+ import * as Rx from 'rxjs';
3
+ export interface PackageDiff {
4
+ added: boolean;
5
+ from?: string;
6
+ name: string;
7
+ realName?: string;
8
+ version?: string;
9
+ deprecated?: boolean;
10
+ latest?: string;
11
+ }
12
+ export interface RecordByString<T> {
13
+ [index: string]: T;
14
+ }
15
+ export declare const propertyByDependencyType: {
16
+ readonly dev: "devDependencies";
17
+ readonly nodeModulesOnly: "node_modules";
18
+ readonly optional: "optionalDependencies";
19
+ readonly peer: "peerDependencies";
20
+ readonly prod: "dependencies";
21
+ };
22
+ export interface PkgsDiff {
23
+ dev: RecordByString<PackageDiff>;
24
+ nodeModulesOnly: RecordByString<PackageDiff>;
25
+ optional: RecordByString<PackageDiff>;
26
+ peer: RecordByString<PackageDiff>;
27
+ prod: RecordByString<PackageDiff>;
28
+ }
29
+ export declare function getPkgsDiff(log$: {
30
+ deprecation: Rx.Observable<logs.DeprecationLog>;
31
+ summary: Rx.Observable<logs.SummaryLog>;
32
+ root: Rx.Observable<logs.RootLog>;
33
+ packageManifest: Rx.Observable<logs.PackageManifestLog>;
34
+ }, opts: {
35
+ prefix?: string;
36
+ }): Rx.Observable<PkgsDiff>;