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
8 changes: 8 additions & 0 deletions .changeset/legal-wombats-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@nodesecure/tree-walker": minor
"@nodesecure/scanner": minor
"@nodesecure/rc": minor
"@nodesecure/tarball": patch
---

Update JS-X-Ray to v14.1.0
2 changes: 1 addition & 1 deletion workspaces/rc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"ajv": "8.18.0"
},
"dependencies": {
"@nodesecure/js-x-ray": "14.0.0",
"@nodesecure/js-x-ray": "14.1.0",
"@nodesecure/npm-types": "^1.2.0",
"@nodesecure/vulnera": "^2.0.1",
"@openally/config": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/scanner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@nodesecure/contact": "^3.0.0",
"@nodesecure/flags": "^3.0.3",
"@nodesecure/i18n": "^4.1.0",
"@nodesecure/js-x-ray": "14.0.0",
"@nodesecure/js-x-ray": "14.1.0",
"@nodesecure/mama": "^2.1.1",
"@nodesecure/npm-registry-sdk": "^4.4.0",
"@nodesecure/npm-types": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/tarball/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dependencies": {
"@nodesecure/conformance": "^1.2.1",
"@nodesecure/fs-walk": "^2.0.0",
"@nodesecure/js-x-ray": "14.0.0",
"@nodesecure/js-x-ray": "14.1.0",
"@nodesecure/mama": "^2.1.1",
"@nodesecure/npm-types": "^1.2.0",
"@nodesecure/utils": "^2.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ export class DependencyCollectableSet implements CollectableSet<Metadata> {
this.#values.add(value);
}

#filerDependencyByKind(dependency: string, relativeFileLocation: string) {
#filerDependencyByKind(
dependency: string,
relativeFileLocation: string = ""
) {
const firstChar = dependency.charAt(0);

/**
Expand Down
9 changes: 7 additions & 2 deletions workspaces/tarball/src/class/SourceCodeScanner.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
AstAnalyser,
type Warning,
type Dependency,
type ReportOnFile
type ReportOnFile,
DefaultCollectableSet
} from "@nodesecure/js-x-ray";
import {
type LocatedManifestManager
Expand Down Expand Up @@ -85,7 +86,11 @@ export class SourceCodeScanner<
) {
const {
reportInitiator = () => new SourceCodeReport(),
astAnalyser = new AstAnalyser()
astAnalyser = new AstAnalyser({
collectables: [
new DefaultCollectableSet("dependency")
]
})
} = options;

this.manifest = manifest;
Expand Down
22 changes: 17 additions & 5 deletions workspaces/tarball/test/SourceCodeScanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import { describe, test } from "node:test";
import {
ManifestManager
} from "@nodesecure/mama";
import { type ReportOnFile, AstAnalyser, DefaultCollectableSet } from "@nodesecure/js-x-ray";
import {
type ReportOnFile,
AstAnalyser,
DefaultCollectableSet
} from "@nodesecure/js-x-ray";

// Import Internal Dependencies
import { DependencyCollectableSet } from "../src/index.ts";
import {
SourceCodeScanner,
type SourceCodeAggregator
Expand Down Expand Up @@ -143,7 +148,10 @@ describe("SourceCodeScanner", () => {

const scanner = new SourceCodeScanner(mama, {
astAnalyser: new AstAnalyser({
collectables: [emailSet]
collectables: [
emailSet,
new DefaultCollectableSet("dependency")
]
})
});
await scanner.iterate({
Expand All @@ -158,7 +166,10 @@ describe("SourceCodeScanner", () => {

test("iterate() should report typescript files", async() => {
const mama = loadFixtureManifest("tsOnly");
const astAnalyser = new AstAnalyser();
const depsSet = new DependencyCollectableSet(mama);
const astAnalyser = new AstAnalyser({
collectables: [depsSet]
});
const aggregator = createAggregator();

const scanner = new SourceCodeScanner(mama, {
Expand All @@ -176,8 +187,9 @@ describe("SourceCodeScanner", () => {

const firstReport = reports[0];
if (firstReport.ok) {
assert.ok(firstReport.dependencies.has("node:http"));
assert.ok(firstReport.dependencies.has("./bar.ts"));
const { files, dependencies } = depsSet.extract();
assert.ok(dependencies.nodeJs.includes("node:http"));
assert.ok(files.has("bar.ts"));
}
else {
assert.fail("First report should be ok");
Expand Down
2 changes: 1 addition & 1 deletion workspaces/tree-walker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/NodeSecure/tree/master/workspaces/tree-walker#readme",
"dependencies": {
"@nodesecure/js-x-ray": "14.0.0",
"@nodesecure/js-x-ray": "14.1.0",
"@nodesecure/npm-registry-sdk": "^4.0.0",
"@nodesecure/npm-types": "^1.1.0",
"@npmcli/arborist": "9.4.0",
Expand Down
Loading