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
6 changes: 6 additions & 0 deletions .changeset/clever-dodos-stand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nodesecure/tree-walker": minor
"@nodesecure/mama": minor
---

Use ManifestManager in NPM TreeWalker class
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@openally/config.typescript/esm-ts-next",
"compilerOptions": {
"composite": true
"composite": true,
"types": ["node"]
}
}
8 changes: 8 additions & 0 deletions workspaces/mama/src/ManifestManager.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ export class ManifestManager<
.some((script) => kUnsafeNPMScripts.has(script.toLowerCase()));
}

get name() {
return this.document.name ?? "workspace";
}

get version() {
return this.document.version ?? "1.0.0";
}

get moduleType() {
return inspectModuleType(this.document);
}
Expand Down
1 change: 1 addition & 0 deletions workspaces/tree-walker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"homepage": "https://github.com/NodeSecure/tree/master/workspaces/tree-walker#readme",
"dependencies": {
"@nodesecure/js-x-ray": "14.2.0",
"@nodesecure/mama": "2.1.1",
"@nodesecure/npm-registry-sdk": "^4.0.0",
"@nodesecure/npm-types": "^1.1.0",
"@npmcli/arborist": "9.4.0",
Expand Down
13 changes: 9 additions & 4 deletions workspaces/tree-walker/src/npm/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os from "node:os";

// Import Third-party Dependencies
import { ManifestManager } from "@nodesecure/mama";
import * as iter from "itertools";
import combineAsyncIterators from "combine-async-iterators";
import pacote from "pacote";
Expand Down Expand Up @@ -308,25 +309,29 @@ export class TreeWalker {
manifest: PackageJSON | WorkspacesPackageJSON | ManifestVersion,
options: WalkOptions = {}
): AsyncIterableIterator<DependencyJSON> {
const mama = new ManifestManager(manifest);

this.relationsMap.clear();
const {
maxDepth = Infinity,
packageLock = null,
includeDevDeps = false
} = options;

const { dependencies, customResolvers, alias } = utils.mergeDependencies(manifest);
const { dependencies, customResolvers, alias } = utils.mergeDependencies(
mama.document
);
const rootDependency = new Dependency(
manifest?.name ?? "workspace",
manifest?.version ?? "1.0.0",
mama.name,
mama.version,
{
alias: Object.fromEntries(alias)
}
);

try {
const { _integrity: integrity } = await this.providers.pacote.manifest(
`${manifest.name}@${manifest.version}`,
mama.spec,
this.registryOptions
);
rootDependency.integrity = integrity;
Expand Down
3 changes: 3 additions & 0 deletions workspaces/tree-walker/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"references": [
{
"path": "../npm-types"
},
{
"path": "../mama"
}
]
}
Loading