Skip to content
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
7 changes: 7 additions & 0 deletions .changeset/silent-baboons-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@nodesecure/tree-walker": minor
"@nodesecure/scanner": minor
"@nodesecure/tarball": minor
---

Implement new DependencyVersion type to detect the kind of module (cjs/esm/dual..)
2 changes: 2 additions & 0 deletions workspaces/scanner/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Import Third-party Dependencies
import type { Warning, WarningDefault } from "@nodesecure/js-x-ray";
import * as Vulnera from "@nodesecure/vulnera";
import type { PackageModuleType } from "@nodesecure/mama";

import type { SpdxFileLicenseConformance } from "@nodesecure/conformance";
import type { IlluminatedContact } from "@nodesecure/contact";
Expand Down Expand Up @@ -48,6 +49,7 @@ export interface Repository {
export interface DependencyVersion {
/** Id of the package (useful for usedBy relation) */
id: number;
type: PackageModuleType;
isDevDependency: boolean;
/**
* Tell if the given package exist on the configured remote registry (npm by default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"versions": {
"1.5.1": {
"id": 0,
"type": "cjs",
"usedBy": {},
"isDevDependency": false,
"existOnRemoteRegistry": true,
Expand Down
7 changes: 6 additions & 1 deletion workspaces/tarball/src/tarball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
} from "@nodesecure/js-x-ray";
import pacote from "pacote";
import * as conformance from "@nodesecure/conformance";
import { ManifestManager } from "@nodesecure/mama";
import {
ManifestManager,
type PackageModuleType
} from "@nodesecure/mama";

// Import Internal Dependencies
import {
Expand All @@ -24,6 +27,7 @@ import * as sast from "./sast/index.js";

export interface DependencyRef {
id: number;
type: PackageModuleType;
usedBy: Record<string, string>;
isDevDependency: boolean;
existOnRemoteRegistry: boolean;
Expand Down Expand Up @@ -144,6 +148,7 @@ export async function scanDirOrArchive(
{ mama, tryDependencies }
);

ref.type = mama.moduleType;
ref.size = composition.size;
ref.composition.extensions.push(...composition.ext);
ref.composition.files.push(...composition.files);
Expand Down
3 changes: 3 additions & 0 deletions workspaces/tree-walker/src/Dependency.class.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Import Third-party Dependencies
import type { Warning, WarningDefault } from "@nodesecure/js-x-ray";
import type { PackageModuleType } from "@nodesecure/mama";

export type NpmSpec = `${string}@${string}`;

export interface DependencyJSON {
id: number;
type: PackageModuleType;
name: string;
version: string;
usedBy: Record<string, string>;
Expand Down Expand Up @@ -99,6 +101,7 @@ export class Dependency {

return {
id: typeof customId === "number" ? customId : Dependency.currentId++,
type: "cjs",
name: this.name,
version: this.version,
usedBy: this.parent,
Expand Down
2 changes: 2 additions & 0 deletions workspaces/tree-walker/test/npm/TreeWalker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe("npm.TreeWalker", () => {
dependency,
{
id: 0,
type: "cjs",
name: "@nodesecure/fs-walk",
version: "2.0.0",
usedBy: {},
Expand Down Expand Up @@ -62,6 +63,7 @@ describe("npm.TreeWalker", () => {
dependency,
{
id: 0,
type: "cjs",
name: "@nodesecure/fs-walk",
version: "2.0.0",
usedBy: {},
Expand Down