Skip to content

Commit

Permalink
feat: universal support for license info
Browse files Browse the repository at this point in the history
  • Loading branch information
gabidobo committed Dec 5, 2022
1 parent 2af5cd5 commit 6b8817f
Show file tree
Hide file tree
Showing 7 changed files with 3,116 additions and 3,115 deletions.
11 changes: 9 additions & 2 deletions .sinkchart/sinkchart@1.3.0-tree.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions .sinkchart/sinkchart@1.3.0-treemap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"d3-node": "3.0.0",
"ora": "6.1.2",
"sandworm-utils": "1.9.0",
"sandworm-utils": "1.10.2",
"yargs": "17.6.0"
},
"devDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion src/charts/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ const setupTooltips = (options) => {
if (licenseName !== false) {
html +=
'<div style="padding: 2px; background: #777; color: white; margin: 2px 0;">License</div>';
html += `<div>${licenseName || '🔴 UNKNOWN'}</div>`;
if (!licenseName) {
html += '<div>🔴 UNKNOWN</div>';
} else if (licenseName.toUpperCase() === 'UNLICENSED') {
html += '<div>🔴 COMMERCIAL</div>';
} else {
html += `<div>${licenseName}</div>`;
}

}

return html;
Expand Down
6 changes: 4 additions & 2 deletions src/charts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ const getIssueLevel = (d, vulnerabilities, includeLicenseIssues = false) => {
return 'indirect';
}

if (includeLicenseIssues && !d.data.license) {
return 'direct';
if (includeLicenseIssues) {
if (!d.data.license || d.data.license.toUpperCase() === 'UNLICENSED') {
return 'direct';
}
}

return 'none';
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const getChartsSVG = async ({
showVersions = false,
width = 1500,
maxDepth = 7,
showLicenseInfo = true,
onProgress = () => {},
}) => {
let packageTree;
Expand Down Expand Up @@ -40,8 +41,7 @@ const getChartsSVG = async ({
maxDepth,
vulnerabilities,
includeDev,
// Only npm produces license info for now
showLicenseInfo: packageTree.meta.packageManager === 'npm',
showLicenseInfo,
onProgress: (message) => onProgress({type: 'update', stage: 'chart', message}),
};

Expand Down
Loading

0 comments on commit 6b8817f

Please sign in to comment.