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

Standalone isomorphic url generator #1

Open
fabiospampinato opened this issue Mar 13, 2024 · 4 comments
Open

Standalone isomorphic url generator #1

fabiospampinato opened this issue Mar 13, 2024 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@fabiospampinato
Copy link

Hello, I'd like to make a little vscode extension for opening a project's package.json in npmgraph, and I'd like to reuse the logic that already exists for this in this module, but I don't really need a CLI, I just need a lower-level function that presumably receives the parsed package.json and returns a url.

Can something like this be implemented?

@fabiospampinato fabiospampinato changed the title Standalone isomorphic opener Standalone isomorphic url generator Mar 13, 2024
@broofa
Copy link
Contributor

broofa commented Mar 13, 2024

To be clear, what I hear you asking for is an SDK, a JS package that can be used to programmatically generate npmgraph URLs... right?

This is actually a good idea. I'd be happy to take a look at a PR if you want to put something together. I'd suggest you start by refactoring the code here to have two workspaces: packages/cli and packages/sdk that can each be published as their own NPM package.

@broofa broofa added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Mar 13, 2024
@fabiospampinato
Copy link
Author

Yeah just a little npm package that exports a function for mapping packages into urls basically.

@fabiospampinato
Copy link
Author

I just published the extension. In the end I could make do with something as simple as this:

`https://npmgraph.js.org/?q=${encodeURIComponent ( `${pkg.name}@${pkg.version}` )}#packages=${encodeURIComponent ( JSON.stringify ( [pkg] ) )}`

@fregante
Copy link
Member

fregante commented Jul 22, 2024

I'd also use it to replace this code:

https://github.com/npmhub/npmhub/blob/908bfdbe1e275fc79f150404d3ddb976f68d19c0/source/components/HeaderLinkNpmGraph.svelte#L5-L11

I'm not sure if the extract complexity in this repo is worth it though. Maybe having a copy-pastable file would be good enough to simplify/expand this readme section: https://github.com/npmgraph/npmgraph#packages-hash-param-json-encoded

… or just publish a standalone package/repo, it's not like the format will change often.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants