anvaka / npmgraph.an

2d visualization of npm
https://npm.anvaka.com
MIT License
1.22k stars 83 forks source link

Analyze any package.json, not just npm packages #24

Closed ccoenen closed 5 years ago

ccoenen commented 6 years ago

I'm helping out with a node.js project which is not itself a npm package. I would love to just toss this URL into the seach field and get its dependencies (or, of course, any other packe.json):

https://raw.githubusercontent.com/hackmdio/hackmd/master/package.json

anvaka commented 6 years ago

I like this suggestion!

I made it work for the basic case, e.g. for this repository: http://npm.anvaka.com/#/view/2d/https%253A%252F%252Fraw.githubusercontent.com%252Fanvaka%252Fnpmgraph.an%252Fmaster%252Fpackage.json

For some reason it doesn't work for https://raw.githubusercontent.com/hackmdio/hackmd/master/package.json . I can look into this later, but the package that builds dependencies graph is here - https://github.com/anvaka/npmgraphbuilder if someone wants to dig deeper - please feel free to!

ccoenen commented 6 years ago

After a bit of fiddling with the graphbuilder, I believe the -ce suffix of 1.1.1-ce is to blame.

If I toss the exact version string into the demo, it works:

diff --git a/demo/index.js b/demo/index.js
index 91cabbf..20b519a 100644
--- a/demo/index.js
+++ b/demo/index.js
@@ -4,7 +4,7 @@ var graphBuilder = require('../')(httpClient);
 var pkgName = process.argv[2] || 'browserify';
 console.log('building dependencies graph for', pkgName);

-graphBuilder.createNpmDependenciesGraph(pkgName, graph).
+graphBuilder.createNpmDependenciesGraph(pkgName, graph, '1.1.1-ce').
   then(function (graph) {
     console.log('Done.');
     console.log('Nodes count: ', graph.getNodesCount());

the -ce is supposed to mean "community edition", but it's not a good idea to put it in that place as it is taken as "prerelease" by semver.

ccoenen commented 5 years ago

It works now, I believe the reason is that the project dropped the -ce suffix.

I'll close this. if this comes up again anywhere, someone can reopen this as a bug.