@pnpm/cli.default-reporter 1100.3.11 → 1100.3.13

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 (61) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/lib/cli.d.ts +1 -0
  3. package/lib/cli.js +50 -0
  4. package/lib/constants.d.ts +1 -0
  5. package/lib/constants.js +4 -0
  6. package/lib/index.d.ts +54 -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 +426 -0
  11. package/lib/reporterForClient/index.d.ts +53 -0
  12. package/lib/reporterForClient/index.js +98 -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 +197 -0
  35. package/lib/reporterForClient/reportLockfileVerification.d.ts +15 -0
  36. package/lib/reporterForClient/reportLockfileVerification.js +73 -0
  37. package/lib/reporterForClient/reportMisc.d.ts +17 -0
  38. package/lib/reporterForClient/reportMisc.js +69 -0
  39. package/lib/reporterForClient/reportPeerDependencyIssues.d.ts +7 -0
  40. package/lib/reporterForClient/reportPeerDependencyIssues.js +11 -0
  41. package/lib/reporterForClient/reportProgress.d.ts +16 -0
  42. package/lib/reporterForClient/reportProgress.js +123 -0
  43. package/lib/reporterForClient/reportRequestRetry.d.ts +5 -0
  44. package/lib/reporterForClient/reportRequestRetry.js +18 -0
  45. package/lib/reporterForClient/reportScope.d.ts +8 -0
  46. package/lib/reporterForClient/reportScope.js +41 -0
  47. package/lib/reporterForClient/reportSkippedOptionalDependencies.d.ts +7 -0
  48. package/lib/reporterForClient/reportSkippedOptionalDependencies.js +8 -0
  49. package/lib/reporterForClient/reportStats.d.ts +13 -0
  50. package/lib/reporterForClient/reportStats.js +143 -0
  51. package/lib/reporterForClient/reportSummary.d.ts +19 -0
  52. package/lib/reporterForClient/reportSummary.js +79 -0
  53. package/lib/reporterForClient/reportUpdateCheck.d.ts +8 -0
  54. package/lib/reporterForClient/reportUpdateCheck.js +42 -0
  55. package/lib/reporterForClient/utils/formatPrefix.d.ts +2 -0
  56. package/lib/reporterForClient/utils/formatPrefix.js +19 -0
  57. package/lib/reporterForClient/utils/formatWarn.d.ts +1 -0
  58. package/lib/reporterForClient/utils/formatWarn.js +5 -0
  59. package/lib/reporterForClient/utils/zooming.d.ts +4 -0
  60. package/lib/reporterForClient/utils/zooming.js +13 -0
  61. package/package.json +15 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @pnpm/default-reporter
2
2
 
3
+ ## 1100.3.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/cli.meta@1100.0.12
9
+ - @pnpm/config.reader@1101.15.0
10
+ - @pnpm/core-loggers@1100.3.0
11
+ - @pnpm/deps.inspection.peers-issues-renderer@1100.0.10
12
+ - @pnpm/installing.dedupe.issues-renderer@1100.0.3
13
+ - @pnpm/types@1101.7.0
14
+
15
+ ## 1100.3.12
16
+
17
+ ### Patch Changes
18
+
19
+ - Republished every package: the tarballs published by the v11.13.1 through v11.16.0 releases were missing most of their compiled files due to a packing bug [#13164](https://github.com/pnpm/pnpm/issues/13164).
20
+
21
+ - Updated dependencies:
22
+ - @pnpm/cli.meta@1100.0.11
23
+ - @pnpm/config.reader@1101.14.0
24
+ - @pnpm/core-loggers@1100.2.5
25
+ - @pnpm/deps.inspection.peers-issues-renderer@1100.0.9
26
+ - @pnpm/error@1100.1.0
27
+ - @pnpm/installing.dedupe.issues-renderer@1100.0.2
28
+ - @pnpm/installing.dedupe.types@1100.0.2
29
+ - @pnpm/types@1101.6.0
30
+
3
31
  ## 1100.3.11
4
32
 
5
33
  ### Patch Changes
package/lib/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function runCli(argv: readonly string[]): Promise<void>;
package/lib/cli.js ADDED
@@ -0,0 +1,50 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import readline from 'node:readline';
3
+ import { initDefaultReporter } from './index.js';
4
+ export async function runCli(argv) {
5
+ const cmd = argv[0] ?? 'install';
6
+ const emitter = new EventEmitter();
7
+ const streamParser = {
8
+ on: (event, reporter) => {
9
+ emitter.on(event, reporter);
10
+ },
11
+ removeListener: (event, reporter) => {
12
+ emitter.removeListener(event, reporter);
13
+ },
14
+ };
15
+ const close = initDefaultReporter({
16
+ streamParser,
17
+ context: { argv: [cmd] },
18
+ reportingOptions: {
19
+ throttleProgress: 200,
20
+ },
21
+ });
22
+ // initDefaultReporter registers its 'data' listener via setTimeout(0); wait
23
+ // a tick so events emitted from the readline loop below aren't dropped.
24
+ await new Promise((resolve) => {
25
+ setTimeout(resolve, 0);
26
+ });
27
+ try {
28
+ const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
29
+ for await (const line of rl) {
30
+ if (!line)
31
+ continue;
32
+ let parsed;
33
+ try {
34
+ parsed = JSON.parse(line);
35
+ }
36
+ catch {
37
+ continue;
38
+ }
39
+ // Guard against valid JSON that isn't a log object (e.g. `null`,
40
+ // numbers, strings) — the reporter dispatches on `log.name`.
41
+ if (parsed == null || typeof parsed !== 'object')
42
+ continue;
43
+ emitter.emit('data', parsed);
44
+ }
45
+ }
46
+ finally {
47
+ close();
48
+ }
49
+ }
50
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ export declare const EOL = "\n";
@@ -0,0 +1,4 @@
1
+ // In terminals, always Unix line endings are used
2
+ // even on Windows
3
+ export const EOL = '\n';
4
+ //# sourceMappingURL=constants.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { Config, ConfigContext } from '@pnpm/config.reader';
2
+ import type * as logs from '@pnpm/core-loggers';
3
+ import type { LogLevel, StreamParser } from '@pnpm/logger';
4
+ import * as Rx from 'rxjs';
5
+ import type { FilterPkgsDiff } from './reporterForClient/reportSummary.js';
6
+ import { formatWarn } from './reporterForClient/utils/formatWarn.js';
7
+ export { formatWarn };
8
+ export declare function initDefaultReporter(opts: {
9
+ useStderr?: boolean;
10
+ streamParser: StreamParser<logs.Log>;
11
+ reportingOptions?: {
12
+ appendOnly?: boolean;
13
+ logLevel?: LogLevel;
14
+ streamLifecycleOutput?: boolean;
15
+ aggregateOutput?: boolean;
16
+ throttleProgress?: number;
17
+ outputMaxWidth?: number;
18
+ hideAddedPkgsProgress?: boolean;
19
+ hideProgressPrefix?: boolean;
20
+ hideLifecycleOutput?: boolean;
21
+ hideLifecyclePrefix?: boolean;
22
+ approveBuildsInstructionText?: string;
23
+ };
24
+ context: {
25
+ argv: string[];
26
+ config?: Config & ConfigContext;
27
+ env?: NodeJS.ProcessEnv;
28
+ process?: NodeJS.Process;
29
+ };
30
+ filterPkgsDiff?: FilterPkgsDiff;
31
+ }): () => void;
32
+ export declare function toOutput$(opts: {
33
+ streamParser: StreamParser<logs.Log>;
34
+ reportingOptions?: {
35
+ appendOnly?: boolean;
36
+ logLevel?: LogLevel;
37
+ outputMaxWidth?: number;
38
+ streamLifecycleOutput?: boolean;
39
+ aggregateOutput?: boolean;
40
+ throttleProgress?: number;
41
+ hideAddedPkgsProgress?: boolean;
42
+ hideProgressPrefix?: boolean;
43
+ hideLifecycleOutput?: boolean;
44
+ hideLifecyclePrefix?: boolean;
45
+ approveBuildsInstructionText?: string;
46
+ };
47
+ context: {
48
+ argv: string[];
49
+ config?: Config & ConfigContext;
50
+ env?: NodeJS.ProcessEnv;
51
+ process?: NodeJS.Process;
52
+ };
53
+ filterPkgsDiff?: FilterPkgsDiff;
54
+ }): Rx.Observable<string>;
@@ -0,0 +1,4 @@
1
+ import * as Rx from 'rxjs';
2
+ export declare function mergeOutputs(outputs: Array<Rx.Observable<Rx.Observable<{
3
+ msg: string;
4
+ }>>>): Rx.Observable<string>;
@@ -0,0 +1,69 @@
1
+ import * as Rx from 'rxjs';
2
+ import { filter, map, mergeAll, scan } from 'rxjs/operators';
3
+ import { EOL } from './constants.js';
4
+ export function mergeOutputs(outputs) {
5
+ let blockNo = 0;
6
+ let fixedBlockNo = 0;
7
+ let started = false;
8
+ let previousOutput = null;
9
+ return Rx.merge(...outputs).pipe(map((log) => {
10
+ let currentBlockNo = -1;
11
+ let currentFixedBlockNo = -1;
12
+ return log.pipe(map((msg) => {
13
+ if (msg.fixed) {
14
+ if (currentFixedBlockNo === -1) {
15
+ currentFixedBlockNo = fixedBlockNo++;
16
+ }
17
+ return {
18
+ blockNo: currentFixedBlockNo,
19
+ fixed: true,
20
+ msg: msg.msg,
21
+ };
22
+ }
23
+ if (currentBlockNo === -1) {
24
+ currentBlockNo = blockNo++;
25
+ }
26
+ return {
27
+ blockNo: currentBlockNo,
28
+ fixed: false,
29
+ msg: typeof msg === 'string' ? msg : msg.msg, // eslint-disable-line
30
+ prevFixedBlockNo: currentFixedBlockNo,
31
+ };
32
+ }));
33
+ }), mergeAll(), scan((acc, log) => {
34
+ if (log.fixed) {
35
+ acc.fixedBlocks[log.blockNo] = log.msg;
36
+ }
37
+ else {
38
+ delete acc.fixedBlocks[log.prevFixedBlockNo];
39
+ acc.blocks[log.blockNo] = log.msg;
40
+ }
41
+ return acc;
42
+ }, { fixedBlocks: [], blocks: [] }), map((sections) => {
43
+ const fixedBlocks = sections.fixedBlocks.filter(Boolean);
44
+ const nonFixedPart = sections.blocks.filter(Boolean).join(EOL);
45
+ if (fixedBlocks.length === 0) {
46
+ return nonFixedPart;
47
+ }
48
+ const fixedPart = fixedBlocks.join(EOL);
49
+ if (!nonFixedPart) {
50
+ return fixedPart;
51
+ }
52
+ return `${nonFixedPart}${EOL}${fixedPart}`;
53
+ }), filter((msg) => {
54
+ if (started) {
55
+ return true;
56
+ }
57
+ if (msg === '')
58
+ return false;
59
+ started = true;
60
+ return true;
61
+ }), filter((msg) => {
62
+ if (msg !== previousOutput) {
63
+ previousOutput = msg;
64
+ return true;
65
+ }
66
+ return false;
67
+ }));
68
+ }
69
+ //# sourceMappingURL=mergeOutputs.js.map
@@ -0,0 +1,3 @@
1
+ import type { Config } from '@pnpm/config.reader';
2
+ import type { Log } from '@pnpm/core-loggers';
3
+ export declare function reportError(logObj: Log, config?: Config): string | null;
@@ -0,0 +1,426 @@
1
+ import { renderPeerIssues } from '@pnpm/deps.inspection.peers-issues-renderer';
2
+ import { renderDedupeCheckIssues } from '@pnpm/installing.dedupe.issues-renderer';
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
+ // ERR_PNPM_NO_MATURE_MATCHING_VERSION used to come from the resolver
55
+ // with `packageMeta` attached; it now comes from the install / dlx /
56
+ // self-update callers as a plain PnpmError once the resolver has
57
+ // surfaced the violations. `packageMeta` may be undefined, in which
58
+ // case the formatter falls back to the bare title+message.
59
+ return formatNoMatchingVersion(err, logObj);
60
+ case 'ERR_PNPM_RECURSIVE_FAIL':
61
+ return formatRecursiveCommandSummary(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
62
+ case 'ERR_PNPM_BAD_TARBALL_SIZE':
63
+ return reportBadTarballSize(err, logObj);
64
+ case 'ELIFECYCLE':
65
+ return reportLifecycleError(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
66
+ case 'ERR_PNPM_UNSUPPORTED_ENGINE':
67
+ return reportEngineError(logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
68
+ case 'ERR_PNPM_PEER_DEP_ISSUES':
69
+ return reportPeerDependencyIssuesError(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
70
+ case 'ERR_PNPM_DEDUPE_CHECK_ISSUES':
71
+ return reportDedupeCheckIssuesError(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
72
+ case 'ERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER':
73
+ return reportSpecNotSupportedByAnyResolverError(err, logObj); // eslint-disable-line @typescript-eslint/no-explicit-any
74
+ case 'ERR_PNPM_FETCH_401':
75
+ case 'ERR_PNPM_FETCH_403':
76
+ return reportAuthError(err, logObj, config); // eslint-disable-line @typescript-eslint/no-explicit-any
77
+ default: {
78
+ // Errors with unknown error codes are printed with stack trace
79
+ if (!err.code?.startsWith?.('ERR_PNPM_')) {
80
+ return formatGenericError(err.message ?? logObj.message, err.stack);
81
+ }
82
+ return {
83
+ title: err.message ?? '',
84
+ body: logObj.hint,
85
+ };
86
+ }
87
+ }
88
+ }
89
+ return { title: logObj.message };
90
+ }
91
+ function formatPkgNameVer({ name, version }) {
92
+ return version == null
93
+ ? name
94
+ : `${name}@${version}`;
95
+ }
96
+ function formatPkgsStack(pkgsStack) {
97
+ return `This error happened while installing the dependencies of \
98
+ ${formatPkgNameVer(pkgsStack[0])}\
99
+ ${pkgsStack.slice(1).map((pkgInfo) => `${EOL} at ${formatPkgNameVer(pkgInfo)}`).join('')}`;
100
+ }
101
+ function formatNoMatchingVersion(err, msg) {
102
+ // Errors raised by the install/dlx/self-update layer after the resolver
103
+ // surfaces violations may not carry the original packageMeta. In that
104
+ // case the error message alone already names every offending entry,
105
+ // so we just echo it through without the registry-metadata appendix.
106
+ const meta = msg.packageMeta;
107
+ if (!meta) {
108
+ return { title: err.message };
109
+ }
110
+ const latestVersion = meta['dist-tags'].latest;
111
+ let output = `The latest release of ${meta.name} is "${latestVersion}".`;
112
+ const latestTime = meta.time?.[latestVersion];
113
+ if (latestTime) {
114
+ output += ` Published at ${stringifyDate(latestTime)}`;
115
+ }
116
+ output += EOL;
117
+ if (!equals(Object.keys(meta['dist-tags']), ['latest'])) {
118
+ output += EOL + 'Other releases are:' + EOL;
119
+ for (const tag in meta['dist-tags']) {
120
+ if (tag !== 'latest') {
121
+ const version = meta['dist-tags'][tag];
122
+ output += ` * ${tag}: ${version}`;
123
+ const time = meta.time?.[version];
124
+ if (time) {
125
+ output += ` published at ${stringifyDate(time)}`;
126
+ }
127
+ output += EOL;
128
+ }
129
+ }
130
+ }
131
+ output += `${EOL}If you need the full list of all ${Object.keys(meta.versions).length} published versions run "pnpm view ${meta.name} versions".`;
132
+ return {
133
+ title: err.message,
134
+ body: output,
135
+ };
136
+ }
137
+ function stringifyDate(dateStr) {
138
+ const now = Date.now();
139
+ const oneDayAgo = now - 24 * 60 * 60 * 1000;
140
+ const date = new Date(dateStr);
141
+ if (date.getTime() < oneDayAgo) {
142
+ return date.toLocaleDateString();
143
+ }
144
+ return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
145
+ }
146
+ function reportUnexpectedStore(err, msg) {
147
+ return {
148
+ title: err.message,
149
+ body: `The dependencies at "${msg.modulesDir}" are currently linked from the store at "${msg.expectedStorePath}".
150
+
151
+ pnpm now wants to use the store at "${msg.actualStorePath}" to link dependencies.
152
+
153
+ If you want to use the new store location, reinstall your dependencies with "pnpm install".
154
+
155
+ You may change the global store location by running "pnpm config set store-dir <dir> --global".
156
+ (This error may happen if the node_modules was installed with a different major version of pnpm)`,
157
+ };
158
+ }
159
+ function reportUnexpectedVirtualStoreDir(err, msg) {
160
+ return {
161
+ title: err.message,
162
+ body: `The dependencies at "${msg.modulesDir}" are currently symlinked from the virtual store directory at "${msg.expected}".
163
+
164
+ pnpm now wants to use the virtual store at "${msg.actual}" to link dependencies from the store.
165
+
166
+ If you want to use the new virtual store location, reinstall your dependencies with "pnpm install".
167
+
168
+ You may change the virtual store location by changing the value of the virtual-store-dir config.`,
169
+ };
170
+ }
171
+ function reportStoreBreakingChange(msg) {
172
+ let output = `Store path: ${colorPath(msg.storePath)}
173
+
174
+ Run "pnpm install" to recreate node_modules.`;
175
+ if (msg.additionalInformation) {
176
+ output = `${output}${EOL}${EOL}${msg.additionalInformation}`;
177
+ }
178
+ output += formatRelatedSources(msg);
179
+ return {
180
+ title: 'The store used for the current node_modules is incompatible with the current version of pnpm',
181
+ body: output,
182
+ };
183
+ }
184
+ function reportModulesBreakingChange(msg) {
185
+ let output = `node_modules path: ${colorPath(msg.modulesPath)}
186
+
187
+ Run ${highlight('pnpm install')} to recreate node_modules.`;
188
+ if (msg.additionalInformation) {
189
+ output = `${output}${EOL}${EOL}${msg.additionalInformation}`;
190
+ }
191
+ output += formatRelatedSources(msg);
192
+ return {
193
+ title: 'The current version of pnpm is not compatible with the available node_modules structure',
194
+ body: output,
195
+ };
196
+ }
197
+ function formatRelatedSources(msg) {
198
+ let output = '';
199
+ if (!msg.relatedIssue && !msg.relatedPR)
200
+ return output;
201
+ output += EOL;
202
+ if (msg.relatedIssue) {
203
+ output += EOL + `Related issue: ${colorPath(`https://github.com/pnpm/pnpm/issues/${msg.relatedIssue}`)}`;
204
+ }
205
+ if (msg.relatedPR) {
206
+ output += EOL + `Related PR: ${colorPath(`https://github.com/pnpm/pnpm/pull/${msg.relatedPR}`)}`;
207
+ }
208
+ return output;
209
+ }
210
+ function formatGenericError(errorMessage, stack) {
211
+ if (stack) {
212
+ let prettyStack;
213
+ try {
214
+ prettyStack = new StackTracey(stack).asTable();
215
+ }
216
+ catch {
217
+ prettyStack = stack.toString();
218
+ }
219
+ if (prettyStack) {
220
+ return {
221
+ title: errorMessage,
222
+ body: prettyStack,
223
+ };
224
+ }
225
+ }
226
+ return { title: errorMessage };
227
+ }
228
+ function formatErrorSummary(message, code) {
229
+ return `${chalk.bgRed.red('[')}${chalk.bgRed.black(code ?? 'ERROR')}${chalk.bgRed.red(']')} ${chalk.red(message)}`;
230
+ }
231
+ function reportModifiedDependency(msg) {
232
+ return {
233
+ title: 'Packages in the store have been mutated',
234
+ body: `These packages are modified:
235
+ ${msg.modified.map((pkgPath) => colorPath(pkgPath)).join(EOL)}
236
+
237
+ You can run ${highlight('pnpm install --force')} to refetch the modified packages`,
238
+ };
239
+ }
240
+ function reportLockfileBreakingChange(err, _msg) {
241
+ return {
242
+ title: err.message,
243
+ body: `Run with the ${highlight('--force')} parameter to recreate the lockfile.`,
244
+ };
245
+ }
246
+ function formatRecursiveCommandSummary(msg) {
247
+ const output = EOL + `Summary: ${chalk.red(`${msg.failures.length} fails`)}, ${msg.passes} passes` + EOL + EOL +
248
+ msg.failures.map(({ message, prefix }) => {
249
+ return prefix + ':' + EOL + formatErrorSummary(message);
250
+ }).join(EOL + EOL);
251
+ return {
252
+ title: '',
253
+ body: output,
254
+ };
255
+ }
256
+ function reportBadTarballSize(err, _msg) {
257
+ return {
258
+ title: err.message,
259
+ body: `Seems like you have internet connection issues.
260
+ Try running the same command again.
261
+ If that doesn't help, try one of the following:
262
+
263
+ - Set a bigger value for the \`fetch-retries\` config.
264
+ To check the current value of \`fetch-retries\`, run \`pnpm get fetch-retries\`.
265
+ To set a new value, run \`pnpm set fetch-retries <number>\`.
266
+
267
+ - Set \`network-concurrency\` to 1.
268
+ This change will slow down installation times, so it is recommended to
269
+ delete the config once the internet connection is good again: \`pnpm config delete network-concurrency\`
270
+
271
+ NOTE: You may also override configs via flags.
272
+ For instance, \`pnpm install --fetch-retries 5 --network-concurrency 1\``,
273
+ };
274
+ }
275
+ function reportLifecycleError(msg) {
276
+ if (msg.stage === 'test') {
277
+ return { title: 'Test failed. See above for more details.' };
278
+ }
279
+ if (typeof msg.errno === 'number') {
280
+ return { title: `Command failed with exit code ${msg.errno}.` };
281
+ }
282
+ return { title: 'Command failed.' };
283
+ }
284
+ function reportEngineError(msg) {
285
+ let output = '';
286
+ if (msg.wanted.pnpm) {
287
+ output += `\
288
+ Your pnpm version is incompatible with "${msg.packageId}".
289
+
290
+ Expected version: ${msg.wanted.pnpm}
291
+ Got: ${msg.current.pnpm}
292
+
293
+ This is happening because the package's manifest has an engines.pnpm field specified.
294
+ To fix this issue, install the required pnpm version globally.
295
+
296
+ To install the latest version of pnpm, run "pnpm i -g pnpm".
297
+ To check your pnpm version, run "pnpm -v".`;
298
+ }
299
+ if (msg.wanted.node) {
300
+ if (output)
301
+ output += EOL + EOL;
302
+ output += `\
303
+ Your Node version is incompatible with "${msg.packageId}".
304
+
305
+ Expected version: ${msg.wanted.node}
306
+ Got: ${msg.current.node}
307
+
308
+ This is happening because the package's manifest has an engines.node field specified.
309
+ To fix this issue, install the required Node version.`;
310
+ }
311
+ return {
312
+ title: 'Unsupported environment (bad pnpm and/or Node.js version)',
313
+ body: output,
314
+ };
315
+ }
316
+ function reportAuthError(err, msg, config) {
317
+ const foundSettings = [];
318
+ for (const [key, value] of Object.entries(config?.authConfig ?? {})) {
319
+ if (key[0] === '@') {
320
+ foundSettings.push(`${key}=${String(value)}`);
321
+ continue;
322
+ }
323
+ if (key.endsWith('_auth') ||
324
+ key.endsWith('_authToken') ||
325
+ key.endsWith('username') ||
326
+ key.endsWith('_password')) {
327
+ foundSettings.push(`${key}=${hideSecureInfo(key, value)}`);
328
+ }
329
+ }
330
+ let output = msg.hint ? `${msg.hint}${EOL}${EOL}` : '';
331
+ if (foundSettings.length === 0) {
332
+ output += `No authorization settings were found in the configs.
333
+ Try to log in to the registry by running "pnpm login"
334
+ or add the auth tokens manually to the ~/.npmrc file.`;
335
+ }
336
+ else {
337
+ output += `These authorization settings were found:
338
+ ${foundSettings.join('\n')}`;
339
+ }
340
+ return {
341
+ title: err.message,
342
+ body: output,
343
+ };
344
+ }
345
+ function hideSecureInfo(key, value) {
346
+ if (key.endsWith('_password'))
347
+ return '[hidden]';
348
+ if (key.endsWith('_auth') || key.endsWith('_authToken'))
349
+ return `${value.substring(0, 4)}[hidden]`;
350
+ return value;
351
+ }
352
+ function reportPeerDependencyIssuesError(err, msg) {
353
+ const hasMissingPeers = getHasMissingPeers(msg.issuesByProjects);
354
+ const hints = [];
355
+ if (hasMissingPeers) {
356
+ hints.push(`To auto-install peer dependencies, add the following to "pnpm-workspace.yaml" in your project root:
357
+
358
+ autoInstallPeers: true`);
359
+ }
360
+ hints.push(`To disable failing on peer dependency issues, add the following to pnpm-workspace.yaml in your project root:
361
+
362
+ strictPeerDependencies: false`);
363
+ const formattedHints = hints.map((hint) => `hint: ${hint}`).join('\n');
364
+ const rendered = renderPeerIssues(msg.issuesByProjects);
365
+ return {
366
+ title: err.message,
367
+ body: rendered ? `${rendered}\n${formattedHints}` : formattedHints,
368
+ };
369
+ }
370
+ function getHasMissingPeers(issuesByProjects) {
371
+ return Object.values(issuesByProjects)
372
+ .some((issues) => Object.values(issues.missing).flat().some(({ optional }) => !optional));
373
+ }
374
+ function reportDedupeCheckIssuesError(err, msg) {
375
+ return {
376
+ title: err.message,
377
+ body: `\
378
+ ${renderDedupeCheckIssues(msg.dedupeCheckIssues)}
379
+ Run ${chalk.yellow('pnpm dedupe')} to apply the changes above.
380
+ `,
381
+ };
382
+ }
383
+ function reportSpecNotSupportedByAnyResolverError(err, logObj) {
384
+ // If the catalog protocol specifier was sent to a "real resolver", it'll
385
+ // eventually throw a "specifier not supported" error since the catalog
386
+ // protocol is meant to be replaced before it's passed to any of the real
387
+ // resolvers.
388
+ //
389
+ // If this kind of error is thrown, and the dependency bareSpecifier is using the
390
+ // catalog protocol it's most likely because we're trying to install an out of
391
+ // repo dependency that was published incorrectly. For example, it may be been
392
+ // mistakenly published with 'npm publish' instead of 'pnpm publish'. Report a
393
+ // more clear error in this case.
394
+ if (logObj.package?.bareSpecifier?.startsWith('catalog:')) {
395
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
396
+ return reportExternalCatalogProtocolError(err, logObj);
397
+ }
398
+ return {
399
+ title: err.message ?? '',
400
+ body: logObj.hint,
401
+ };
402
+ }
403
+ function reportExternalCatalogProtocolError(err, logObj) {
404
+ const { pkgsStack } = logObj;
405
+ const problemDep = pkgsStack?.[0];
406
+ let body = `\
407
+ An external package outside of the pnpm workspace declared a dependency using
408
+ the catalog protocol. This is likely a bug in that external package. Only
409
+ packages within the pnpm workspace may use catalogs. Usages of the catalog
410
+ protocol are replaced with real specifiers on 'pnpm publish'.
411
+ `;
412
+ if (problemDep != null) {
413
+ body += `\
414
+
415
+ This is likely a bug in the publishing automation of this package. Consider filing
416
+ a bug with the authors of:
417
+
418
+ ${highlight(formatPkgNameVer(problemDep))}
419
+ `;
420
+ }
421
+ return {
422
+ title: err.message,
423
+ body,
424
+ };
425
+ }
426
+ //# sourceMappingURL=reportError.js.map