@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
@@ -0,0 +1,143 @@
1
+ import chalk from 'chalk';
2
+ import { repeat } from 'ramda';
3
+ import * as Rx from 'rxjs';
4
+ import { filter, map, reduce, take } from 'rxjs/operators';
5
+ import stringLength from 'string-length';
6
+ import { EOL } from '../constants.js';
7
+ import { ADDED_CHAR, REMOVED_CHAR, } from './outputConstants.js';
8
+ import { zoomOut } from './utils/zooming.js';
9
+ export function reportStats(log$, opts) {
10
+ if (opts.hideProgressPrefix) {
11
+ return [statsForCurrentPackage(log$.stats, {
12
+ cmd: opts.cmd,
13
+ width: opts.width,
14
+ })];
15
+ }
16
+ const stats$ = opts.isRecursive
17
+ ? log$.stats
18
+ : log$.stats.pipe(filter((log) => log.prefix !== opts.cwd));
19
+ const outputs = [
20
+ statsForNotCurrentPackage(stats$, {
21
+ cmd: opts.cmd,
22
+ currentPrefix: opts.cwd,
23
+ width: opts.width,
24
+ }),
25
+ ];
26
+ if (!opts.isRecursive) {
27
+ outputs.push(statsForCurrentPackage(log$.stats.pipe(filter((log) => log.prefix === opts.cwd)), {
28
+ cmd: opts.cmd,
29
+ width: opts.width,
30
+ }));
31
+ }
32
+ return outputs;
33
+ }
34
+ function statsForCurrentPackage(stats$, opts) {
35
+ return stats$.pipe(take((opts.cmd === 'install' || opts.cmd === 'install-test' || opts.cmd === 'add' || opts.cmd === 'update' || opts.cmd === 'dlx') ? 2 : 1), reduce((acc, log) => {
36
+ if (typeof log['added'] === 'number') {
37
+ acc['added'] = log['added'];
38
+ }
39
+ else if (typeof log['removed'] === 'number') {
40
+ acc['removed'] = log['removed'];
41
+ }
42
+ return acc;
43
+ }, {}), map((stats) => {
44
+ if (!stats['removed'] && !stats['added']) {
45
+ if (opts.cmd === 'link') {
46
+ return Rx.NEVER;
47
+ }
48
+ return Rx.of({ msg: 'Already up to date' });
49
+ }
50
+ let msg = 'Packages:';
51
+ if (stats['added']) {
52
+ msg += ' ' + chalk.green(`+${stats['added'].toString()}`);
53
+ }
54
+ if (stats['removed']) {
55
+ msg += ' ' + chalk.red(`-${stats['removed'].toString()}`);
56
+ }
57
+ msg += EOL + printPlusesAndMinuses(opts.width, (stats['added'] ?? 0), (stats['removed'] ?? 0));
58
+ return Rx.of({ msg });
59
+ }));
60
+ }
61
+ function statsForNotCurrentPackage(stats$, opts) {
62
+ const stats = {};
63
+ const cookedStats$ = (opts.cmd !== 'remove'
64
+ ? stats$.pipe(map((log) => {
65
+ // As of pnpm v2.9.0, during `pnpm recursive link`, logging of removed stats happens twice
66
+ // 1. during linking
67
+ // 2. during installing
68
+ // Hence, the stats are added before reported
69
+ const { prefix } = log;
70
+ if (!stats[prefix]) {
71
+ stats[prefix] = log;
72
+ return { seed: stats, value: null };
73
+ }
74
+ else if (typeof stats[prefix].added === 'number' && typeof log['added'] === 'number') {
75
+ stats[prefix].added += log['added'];
76
+ return { seed: stats, value: null };
77
+ }
78
+ else if (typeof stats[prefix].removed === 'number' && typeof log['removed'] === 'number') {
79
+ stats[prefix].removed += log['removed'];
80
+ return { seed: stats, value: null };
81
+ }
82
+ else {
83
+ const value = { ...stats[prefix], ...log };
84
+ delete stats[prefix];
85
+ return value;
86
+ }
87
+ }, {}))
88
+ : stats$);
89
+ return cookedStats$.pipe(filter((stats) => stats !== null && Boolean(stats['removed'] || stats['added'])), map((stats) => {
90
+ const parts = [];
91
+ if (stats['added']) {
92
+ parts.push(padStep(chalk.green(`+${stats['added'].toString()}`), 4));
93
+ }
94
+ if (stats['removed']) {
95
+ parts.push(padStep(chalk.red(`-${stats['removed'].toString()}`), 4));
96
+ }
97
+ let msg = zoomOut(opts.currentPrefix, stats.prefix, parts.join(' '));
98
+ const rest = Math.max(0, opts.width - 1 - stringLength(msg));
99
+ msg += ' ' + printPlusesAndMinuses(rest, roundStats(stats['added'] || 0), roundStats(stats['removed'] || 0));
100
+ return Rx.of({ msg });
101
+ }));
102
+ }
103
+ function padStep(s, step) {
104
+ const sLength = stringLength(s);
105
+ const placeholderLength = Math.ceil(sLength / step) * step;
106
+ if (sLength < placeholderLength) {
107
+ return repeat(' ', placeholderLength - sLength).join('') + s;
108
+ }
109
+ return s;
110
+ }
111
+ function roundStats(stat) {
112
+ if (stat === 0)
113
+ return 0;
114
+ return Math.max(1, Math.round(stat / 10));
115
+ }
116
+ function printPlusesAndMinuses(maxWidth, added, removed) {
117
+ if (maxWidth === 0)
118
+ return '';
119
+ const changes = added + removed;
120
+ let addedChars;
121
+ let removedChars;
122
+ if (changes > maxWidth) {
123
+ if (!added) {
124
+ addedChars = 0;
125
+ removedChars = maxWidth;
126
+ }
127
+ else if (!removed) {
128
+ addedChars = maxWidth;
129
+ removedChars = 0;
130
+ }
131
+ else {
132
+ const p = maxWidth / changes;
133
+ addedChars = Math.min(Math.max(Math.floor(added * p), 1), maxWidth - 1);
134
+ removedChars = maxWidth - addedChars;
135
+ }
136
+ }
137
+ else {
138
+ addedChars = added;
139
+ removedChars = removed;
140
+ }
141
+ return `${repeat(ADDED_CHAR, addedChars).join('')}${repeat(REMOVED_CHAR, removedChars).join('')}`;
142
+ }
143
+ //# sourceMappingURL=reportStats.js.map
@@ -0,0 +1,19 @@
1
+ import type { Config } from '@pnpm/config.reader';
2
+ import type { DeprecationLog, PackageManifestLog, RootLog, SummaryLog } from '@pnpm/core-loggers';
3
+ import * as Rx from 'rxjs';
4
+ import { type PackageDiff } from './pkgsDiff.js';
5
+ export declare function reportSummary(log$: {
6
+ deprecation: Rx.Observable<DeprecationLog>;
7
+ summary: Rx.Observable<SummaryLog>;
8
+ root: Rx.Observable<RootLog>;
9
+ packageManifest: Rx.Observable<PackageManifestLog>;
10
+ }, opts: {
11
+ cmd: string;
12
+ cwd: string;
13
+ env: NodeJS.ProcessEnv;
14
+ filterPkgsDiff?: FilterPkgsDiff;
15
+ pnpmConfig?: Config;
16
+ }): Rx.Observable<Rx.Observable<{
17
+ msg: string;
18
+ }>>;
19
+ export type FilterPkgsDiff = (pkgsDiff: PackageDiff) => boolean;
@@ -0,0 +1,79 @@
1
+ import path from 'node:path';
2
+ import chalk from 'chalk';
3
+ import * as Rx from 'rxjs';
4
+ import { map, take } from 'rxjs/operators';
5
+ import semver from 'semver';
6
+ import { EOL } from '../constants.js';
7
+ import { ADDED_CHAR, REMOVED_CHAR, } from './outputConstants.js';
8
+ import { getPkgsDiff, propertyByDependencyType, } from './pkgsDiff.js';
9
+ const CONFIG_BY_DEP_TYPE = {
10
+ prod: 'production',
11
+ dev: 'dev',
12
+ optional: 'optional',
13
+ };
14
+ export function reportSummary(log$, opts) {
15
+ const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.pnpmConfig?.global ? undefined : opts.cwd });
16
+ const summaryLog$ = log$.summary.pipe(take(1));
17
+ const _printDiffs = printDiffs.bind(null, { cmd: opts.cmd, prefix: opts.cwd, pnpmConfig: opts.pnpmConfig });
18
+ return Rx.combineLatest(pkgsDiff$, summaryLog$)
19
+ .pipe(take(1), map(([pkgsDiff]) => {
20
+ let msg = '';
21
+ for (const depType of ['prod', 'optional', 'peer', 'dev', 'nodeModulesOnly']) {
22
+ let diffs = Object.values(pkgsDiff[depType]);
23
+ if (opts.filterPkgsDiff) {
24
+ // This filtering is only used by Bit CLI currently.
25
+ // Related PR: https://github.com/teambit/bit/pull/7176
26
+ diffs = diffs.filter((pkgDiff) => opts.filterPkgsDiff(pkgDiff));
27
+ }
28
+ if (diffs.length > 0) {
29
+ msg += EOL;
30
+ msg += chalk.cyanBright(opts.pnpmConfig?.global ? 'global:' : `${propertyByDependencyType[depType]}:`);
31
+ msg += EOL;
32
+ msg += _printDiffs(diffs, depType);
33
+ msg += EOL;
34
+ }
35
+ else if (CONFIG_BY_DEP_TYPE[depType] && opts.pnpmConfig?.[CONFIG_BY_DEP_TYPE[depType]] === false) {
36
+ msg += EOL;
37
+ msg += `${chalk.cyanBright(`${propertyByDependencyType[depType]}:`)} skipped`;
38
+ msg += EOL;
39
+ }
40
+ }
41
+ return Rx.of({ msg });
42
+ }));
43
+ }
44
+ function printDiffs(opts, pkgsDiff, depType) {
45
+ // Sorts by alphabet then by removed/added
46
+ // + ava 0.10.0
47
+ // - chalk 1.0.0
48
+ // + chalk 2.0.0
49
+ pkgsDiff.sort((a, b) => (a.name.localeCompare(b.name) * 10 + (Number(!b.added) - Number(!a.added))));
50
+ const msg = pkgsDiff.map((pkg) => {
51
+ let result = pkg.added
52
+ ? ADDED_CHAR
53
+ : REMOVED_CHAR;
54
+ if (!pkg.realName || pkg.name === pkg.realName) {
55
+ result += ` ${pkg.name}`;
56
+ }
57
+ else {
58
+ result += ` ${pkg.name} <- ${pkg.realName}`;
59
+ }
60
+ if (pkg.version) {
61
+ result += ` ${chalk.grey(pkg.version)}`;
62
+ if (pkg.latest && semver.lt(pkg.version, pkg.latest)) {
63
+ result += ` ${chalk.grey(`(${pkg.latest} is available)`)}`;
64
+ }
65
+ }
66
+ if (pkg.deprecated) {
67
+ result += ` ${chalk.red('deprecated')}`;
68
+ }
69
+ if (pkg.from) {
70
+ result += ` ${chalk.grey(`<- ${path.relative(opts.prefix, pkg.from) || pkg.from}`)}`;
71
+ }
72
+ if (pkg.added && depType === 'dev' && opts.pnpmConfig?.saveDev === false && opts.cmd === 'add') {
73
+ result += `${chalk.yellow(' already in devDependencies, was not moved to dependencies.')}`;
74
+ }
75
+ return result;
76
+ }).join(EOL);
77
+ return msg;
78
+ }
79
+ //# sourceMappingURL=reportSummary.js.map
@@ -0,0 +1,8 @@
1
+ import type { UpdateCheckLog } from '@pnpm/core-loggers';
2
+ import * as Rx from 'rxjs';
3
+ export declare function reportUpdateCheck(log$: Rx.Observable<UpdateCheckLog>, opts: {
4
+ env: NodeJS.ProcessEnv;
5
+ process: NodeJS.Process;
6
+ }): Rx.Observable<Rx.Observable<{
7
+ msg: string;
8
+ }>>;
@@ -0,0 +1,42 @@
1
+ import { detectIfCurrentPkgIsExecutable, isExecutedByCorepack } from '@pnpm/cli.meta';
2
+ import boxen from 'boxen';
3
+ import chalk from 'chalk';
4
+ import * as Rx from 'rxjs';
5
+ import { filter, map, take } from 'rxjs/operators';
6
+ import semver from 'semver';
7
+ export function reportUpdateCheck(log$, opts) {
8
+ return log$.pipe(take(1), filter((log) => semver.gt(log.latestVersion, log.currentVersion)), map((log) => {
9
+ const updateMessage = renderUpdateMessage({
10
+ currentPkgIsExecutable: detectIfCurrentPkgIsExecutable(opts.process),
11
+ latestVersion: log.latestVersion,
12
+ env: opts.env,
13
+ });
14
+ return Rx.of({
15
+ msg: boxen(`\
16
+ Update available! ${chalk.red(log.currentVersion)} → ${chalk.green(log.latestVersion)}.
17
+ ${chalk.magenta('Changelog:')} https://pnpm.io/v/${log.latestVersion}
18
+ ${updateMessage}`, {
19
+ padding: 1,
20
+ margin: 1,
21
+ align: 'center',
22
+ borderColor: 'yellow',
23
+ borderStyle: 'round',
24
+ }),
25
+ });
26
+ }));
27
+ }
28
+ function renderUpdateMessage(opts) {
29
+ const updateCommand = renderUpdateCommand(opts);
30
+ return `To update, run: ${chalk.magenta(updateCommand)}`;
31
+ }
32
+ function renderUpdateCommand(opts) {
33
+ if (isExecutedByCorepack(opts.env)) {
34
+ return `corepack use pnpm@${opts.latestVersion}`;
35
+ }
36
+ if (opts.env.PNPM_HOME) {
37
+ return 'pnpm self-update';
38
+ }
39
+ const pkgName = opts.currentPkgIsExecutable ? '@pnpm/exe' : 'pnpm';
40
+ return `pnpm add -g ${pkgName}`;
41
+ }
42
+ //# sourceMappingURL=reportUpdateCheck.js.map
@@ -0,0 +1,2 @@
1
+ export declare function formatPrefix(cwd: string, prefix: string): string;
2
+ export declare function formatPrefixNoTrim(cwd: string, prefix: string): string;
@@ -0,0 +1,19 @@
1
+ import path from 'node:path';
2
+ import normalize from 'normalize-path';
3
+ import { PREFIX_MAX_LENGTH } from '../outputConstants.js';
4
+ export function formatPrefix(cwd, prefix) {
5
+ prefix = formatPrefixNoTrim(cwd, prefix);
6
+ if (prefix.length <= PREFIX_MAX_LENGTH) {
7
+ return prefix;
8
+ }
9
+ const shortPrefix = prefix.slice(-PREFIX_MAX_LENGTH + 3);
10
+ const separatorLocation = shortPrefix.indexOf('/');
11
+ if (separatorLocation <= 0) {
12
+ return `...${shortPrefix}`;
13
+ }
14
+ return `...${shortPrefix.slice(separatorLocation)}`;
15
+ }
16
+ export function formatPrefixNoTrim(cwd, prefix) {
17
+ return normalize(path.relative(cwd, prefix) || '.');
18
+ }
19
+ //# sourceMappingURL=formatPrefix.js.map
@@ -0,0 +1 @@
1
+ export declare function formatWarn(message: string): string;
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+ export function formatWarn(message) {
3
+ return `${chalk.bgYellow.yellow('[')}${chalk.bgYellow.black('WARN')}${chalk.bgYellow.yellow(']')} ${message}`;
4
+ }
5
+ //# sourceMappingURL=formatWarn.js.map
@@ -0,0 +1,4 @@
1
+ export declare function autozoom(currentPrefix: string, logPrefix: string | undefined, line: string, opts: {
2
+ zoomOutCurrent: boolean;
3
+ }): string;
4
+ export declare function zoomOut(currentPrefix: string, logPrefix: string, line: string): string;
@@ -0,0 +1,13 @@
1
+ import { PREFIX_MAX_LENGTH } from '../outputConstants.js';
2
+ import { formatPrefix } from './formatPrefix.js';
3
+ export function autozoom(currentPrefix, logPrefix, line, opts) {
4
+ if (!logPrefix || !opts.zoomOutCurrent && currentPrefix === logPrefix) {
5
+ return line;
6
+ }
7
+ return zoomOut(currentPrefix, logPrefix, line);
8
+ }
9
+ export function zoomOut(currentPrefix, logPrefix, line) {
10
+ const prefix = formatPrefix(currentPrefix, logPrefix);
11
+ return `${prefix.padEnd(PREFIX_MAX_LENGTH)} | ${line}`;
12
+ }
13
+ //# sourceMappingURL=zooming.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/cli.default-reporter",
3
- "version": "1100.3.11",
3
+ "version": "1100.3.13",
4
4
  "description": "The default reporter of pnpm",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -32,25 +32,25 @@
32
32
  "pnpm-render": "bin/pnpm-render.mjs"
33
33
  },
34
34
  "dependencies": {
35
- "@pnpm/cli.meta": "1100.0.10",
36
- "@pnpm/config.reader": "1101.13.0",
37
- "@pnpm/core-loggers": "1100.2.4",
38
- "@pnpm/deps.inspection.peers-issues-renderer": "1100.0.8",
39
- "@pnpm/error": "1100.0.1",
40
- "@pnpm/installing.dedupe.issues-renderer": "1100.0.1",
41
- "@pnpm/installing.dedupe.types": "1100.0.1",
42
- "@pnpm/types": "1101.5.0",
35
+ "@pnpm/cli.meta": "1100.0.12",
36
+ "@pnpm/config.reader": "1101.15.0",
37
+ "@pnpm/core-loggers": "1100.3.0",
38
+ "@pnpm/deps.inspection.peers-issues-renderer": "1100.0.10",
39
+ "@pnpm/error": "1100.1.0",
40
+ "@pnpm/installing.dedupe.issues-renderer": "1100.0.3",
41
+ "@pnpm/installing.dedupe.types": "1100.0.2",
42
+ "@pnpm/types": "1101.7.0",
43
43
  "@pnpm/util.lex-comparator": "^4.0.1",
44
44
  "ansi-diff": "^1.2.0",
45
45
  "boxen": "npm:@zkochan/boxen@5.1.2",
46
- "chalk": "^5.6.2",
47
- "cli-truncate": "^6.0.0",
46
+ "chalk": "^6.0.0",
47
+ "cli-truncate": "^6.1.1",
48
48
  "normalize-path": "^3.0.0",
49
- "pretty-bytes": "^7.1.0",
49
+ "pretty-bytes": "^7.1.1",
50
50
  "pretty-ms": "^9.3.0",
51
51
  "ramda": "npm:@pnpm/ramda@0.28.1",
52
52
  "rxjs": "^7.8.2",
53
- "semver": "^7.8.4",
53
+ "semver": "^7.8.5",
54
54
  "stacktracey": "^2.2.0",
55
55
  "string-length": "^7.0.1"
56
56
  },
@@ -59,10 +59,10 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@jest/globals": "30.4.1",
62
- "@pnpm/cli.default-reporter": "1100.3.11",
62
+ "@pnpm/cli.default-reporter": "1100.3.13",
63
63
  "@pnpm/logger": "1100.0.0",
64
64
  "@types/normalize-path": "^3.0.2",
65
- "@types/ramda": "0.31.1",
65
+ "@types/ramda": "0.32.0",
66
66
  "@types/semver": "7.7.1",
67
67
  "ghooks": "2.0.4",
68
68
  "load-json-file": "^7.0.1",