@pnpm/render-peer-issues
Advanced tools
Comparing version 0.0.0 to 1.0.0
@@ -1,2 +0,4 @@ | ||
import { PeerDependencyIssues } from '@pnpm/types'; | ||
export default function (peerDependencyIssues: PeerDependencyIssues): string; | ||
import { PeerDependencyIssuesByProjects } from '@pnpm/types'; | ||
export default function (peerDependencyIssuesByProjects: PeerDependencyIssuesByProjects, opts?: { | ||
width?: number; | ||
}): string; |
@@ -8,29 +8,51 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const ROOT_LABEL = '<ROOT>'; | ||
function default_1(peerDependencyIssues) { | ||
const cli_columns_1 = __importDefault(require("cli-columns")); | ||
function default_1(peerDependencyIssuesByProjects, opts) { | ||
var _a; | ||
const projects = {}; | ||
for (const [peerName, issues] of Object.entries(peerDependencyIssues.missing)) { | ||
for (const issue of issues) { | ||
const projectPath = issue.location.projectPath || ROOT_LABEL; | ||
if (!projects[projectPath]) { | ||
projects[projectPath] = { dependencies: {}, peerIssues: [] }; | ||
for (const [projectId, { bad, missing, conflicts, intersections }] of Object.entries(peerDependencyIssuesByProjects)) { | ||
projects[projectId] = { dependencies: {}, peerIssues: [] }; | ||
for (const [peerName, issues] of Object.entries(missing)) { | ||
if (!conflicts.includes(peerName) && | ||
intersections[peerName] == null) { | ||
continue; | ||
} | ||
createTree(projects[projectPath], issue.location.parents, `${chalk_1.default.red('✕ missing peer')} ${peerName}@"${issue.wantedRange}"`); | ||
for (const issue of issues) { | ||
createTree(projects[projectId], issue.parents, `${chalk_1.default.red('✕ missing peer')} ${formatNameAndRange(peerName, issue.wantedRange)}`); | ||
} | ||
} | ||
} | ||
for (const [peerName, issues] of Object.entries(peerDependencyIssues.bad)) { | ||
for (const issue of issues) { | ||
const projectPath = issue.location.projectPath || ROOT_LABEL; | ||
if (!projects[projectPath]) { | ||
projects[projectPath] = { dependencies: {}, peerIssues: [] }; | ||
for (const [peerName, issues] of Object.entries(bad)) { | ||
for (const { parents, foundVersion, wantedRange } of issues) { | ||
// eslint-disable-next-line | ||
createTree(projects[projectId], parents, `${chalk_1.default.red('✕ unmet peer')} ${formatNameAndRange(peerName, wantedRange)}: found ${foundVersion}`); | ||
} | ||
// eslint-disable-next-line | ||
createTree(projects[projectPath], issue.location.parents, `${chalk_1.default.red('✕ unmet peer')} ${peerName}@"${issue.wantedRange}": found ${issue.foundVersion}`); | ||
} | ||
} | ||
const cliColumnsOptions = { | ||
newline: '\n ', | ||
width: ((_a = opts === null || opts === void 0 ? void 0 : opts.width) !== null && _a !== void 0 ? _a : process.stdout.columns) - 2, | ||
}; | ||
return Object.entries(projects) | ||
.filter(([, project]) => Object.keys(project.dependencies).length > 0) | ||
.sort(([projectKey1], [projectKey2]) => projectKey1.localeCompare(projectKey2)) | ||
.map(([projectKey, project]) => (0, archy_1.default)(toArchyData(projectKey, project))).join(''); | ||
.map(([projectKey, project]) => { | ||
let summary = ''; | ||
const { conflicts, intersections } = peerDependencyIssuesByProjects[projectKey]; | ||
if (conflicts.length) { | ||
summary += chalk_1.default.red(`✕ Conflicting peer dependencies:\n ${(0, cli_columns_1.default)(conflicts, cliColumnsOptions)}`); | ||
} | ||
if (Object.keys(intersections).length) { | ||
summary += `Peer dependencies that should be installed:\n ${(0, cli_columns_1.default)(Object.entries(intersections).map(([name, version]) => formatNameAndRange(name, version)), cliColumnsOptions)}`; | ||
} | ||
const title = chalk_1.default.white(projectKey); | ||
return `${(0, archy_1.default)(toArchyData(title, project))}${summary}`; | ||
}).join('\n\n'); | ||
} | ||
exports.default = default_1; | ||
function formatNameAndRange(name, range) { | ||
if (range.includes(' ')) { | ||
return `${name}@"${range}"`; | ||
} | ||
return `${name}@${range}`; | ||
} | ||
function createTree(pkgNode, pkgs, issueText) { | ||
@@ -37,0 +59,0 @@ const [pkg, ...rest] = pkgs; |
{ | ||
"name": "@pnpm/render-peer-issues", | ||
"description": "Visualizes peer dependency issues", | ||
"version": "0.0.0", | ||
"version": "1.0.0", | ||
"bugs": { | ||
@@ -25,5 +25,6 @@ "url": "https://github.com/pnpm/pnpm/issues" | ||
"dependencies": { | ||
"@pnpm/types": "7.6.0", | ||
"@pnpm/types": "7.7.0", | ||
"archy": "^1.0.0", | ||
"chalk": "^4.1.0" | ||
"chalk": "^4.1.0", | ||
"cli-columns": "^4.0.0" | ||
}, | ||
@@ -30,0 +31,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9613
84
0
4
+ Addedcli-columns@^4.0.0
+ Added@pnpm/types@7.7.0(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedcli-columns@4.0.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
- Removed@pnpm/types@7.6.0(transitive)
Updated@pnpm/types@7.7.0