Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs #286

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/css/views/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@
border-radius: 4px;
}

.home--warnings>p + p {
margin-top: 5px;
}

/**
* WARNINGS END
*/
Expand Down
3 changes: 3 additions & 0 deletions public/js/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ export class HomeView {

for (let id = 0; id < authors.length; id++) {
const [name, data] = authors[id];
if (typeof name === "undefined") {
continue;
}
const { count, email, url = null } = data;

const hasURL = typeof url === "string";
Expand Down
13 changes: 10 additions & 3 deletions public/js/components/package/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ export class PackageHeader {
if (flagFragment) {
flagsDomElement.appendChild(flagFragment);
}
else {
flagsDomElement.style.display = "none";
}

return links;
}
Expand Down Expand Up @@ -197,6 +194,11 @@ export class PackageHeader {
}

renderFlags(flags) {
const { warnings } = this.package.dependencyVersion;
const warningsLength = warnings.filter(
(warning) => !window.settings.config.ignore.warnings.has(warning.kind)
).length;

const textContent = getFlagsEmojisInlined(flags, new Set(window.settings.config.ignore.flags));

if (textContent === "") {
Expand All @@ -216,6 +218,11 @@ export class PackageHeader {
const fragment = document.createDocumentFragment();
for (const icon of Array.from(segitr, ({ segment }) => segment)) {
if (flagsMap.has(icon)) {
const { name } = flagsMap.get(icon);
if (name === "warnings" && warningsLength === 0) {
continue;
}

const tooltipElement = utils.createTooltip(icon, flagsMap.get(icon).tooltipDescription);
tooltipElement.addEventListener("click", () => {
const { name } = flagsMap.get(icon);
Expand Down
14 changes: 12 additions & 2 deletions public/js/components/package/pannels/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ export class Scripts {
generate(clone) {
this.setupSignal(clone);

clone.querySelector(".package-scripts")
.appendChild(this.renderScripts());
const fragment = this.renderScripts();
const packageScriptsElement = clone.querySelector(".package-scripts");
if (fragment === null) {
clone.getElementById("script-title").style.display = "none";
packageScriptsElement.style.display = "none";
}
else {
packageScriptsElement.appendChild(this.renderScripts());
}
this.renderDependencies(clone);
this.showHideDependenciesInTree(clone);
}
Expand All @@ -48,6 +55,9 @@ export class Scripts {
const createPElement = (className, text) => utils.createDOMElement("p", { className, text });

const scripts = Object.entries(this.package.dependencyVersion.scripts);
if (scripts.length === 0) {
return null;
}
const hideItemsLength = 4;
const hideItems = scripts.length > hideItemsLength;

Expand Down
7 changes: 4 additions & 3 deletions public/js/components/package/pannels/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export class Warnings {

const id = Math.random().toString(36).slice(2);
const hasNoInspection =
warning.file.includes(".min") &&
warning.kind === "short-identifiers" &&
warning.kind === "obfuscated-code";
warning.file.includes(".min") ||
warning.kind === "short-identifiers" ||
warning.kind === "obfuscated-code" ||
warning.kind === "zero-semver";

const viewMoreElement = utils.createDOMElement("div", {
className: "view-more",
Expand Down
5 changes: 4 additions & 1 deletion public/js/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ document.addEventListener("DOMContentLoaded", async () => {
window.settings.config.ignore.warnings = warningsToIgnore;
window.settings.config.ignore.flags = flagsToIgnore;

await secureDataSet.init(secureDataSet.data);
await secureDataSet.init(
secureDataSet.data,
secureDataSet.FLAGS
);
const { nodes } = secureDataSet.build();
nsn.nodes.update(nodes.get());

Expand Down
6 changes: 3 additions & 3 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ <h1><i class="icon-cog"></i>General</h1>
<p>weak crypto</p>
</div>
<div>
<input type="checkbox" checked name="warnings" value="invalid-semver">
<p>invalid semver (0.x.x)</p>
<input type="checkbox" checked name="warnings" value="zero-semver">
<p>zero semver (0.x.x)</p>
</div>
</div>
<div class="line">
Expand Down Expand Up @@ -383,7 +383,7 @@ <h1><i class="icon-cog"></i>General</h1>
</div>

<div class="package-container hidden" id="pan-dependencies">
<div class="head-title no-margin">
<div class="head-title no-margin" id="script-title">
<p>npm scripts</p>
</div>
<div class="package-scripts"></div>
Expand Down
21 changes: 15 additions & 6 deletions workspaces/vis-network/src/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export default class NodeSecureDataSet extends EventTarget {

this.flagsToIgnore = new Set(flagsToIgnore);
this.warningsToIgnore = new Set(warningsToIgnore);
this.reset();
}

get prettySize() {
return prettyBytes(this.size);
}

reset() {
this.warnings = [];
this.packages = [];
this.linker = new Map();
Expand All @@ -34,13 +42,14 @@ export default class NodeSecureDataSet extends EventTarget {
this.indirectDependencies = 0;
}

get prettySize() {
return prettyBytes(this.size);
}

async init(initialPayload = null, initialFlags = {}) {
async init(
initialPayload = null,
initialFlags = {}
) {
console.log("[NodeSecureDataSet] Initialization started...");
let FLAGS; let data;
let FLAGS;
let data;
this.reset();

if (initialPayload) {
data = initialPayload;
Expand Down
Loading