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

Question: can i override a node's prefix via criteria ? #852

Closed
CaptainQuirk opened this issue Oct 16, 2023 · 7 comments · Fixed by #854
Closed

Question: can i override a node's prefix via criteria ? #852

CaptainQuirk opened this issue Oct 16, 2023 · 7 comments · Fixed by #854

Comments

@CaptainQuirk
Copy link

I would like to change the prefix or the href for specific nodes

Summary

  • I'm perfectly fine with how things work for code under version control and can add the URL to my gitlab instance in the configuration file under the prefix option BUT I would like to be able to link to node packages when the dependency type is npm

Environment

  • Version used: 14.1.1
  • Node version: 18.17.0
  • Operating System and version: alpine node
  • Link to your project:
sverweij added a commit to sverweij/sverweij.github.io that referenced this issue Oct 16, 2023
@sverweij
Copy link
Owner

sverweij commented Oct 16, 2023

Hi @CaptainQuirk thanks for this suggestion. It's not possible (yet), but it makes a lot of sense. Likewise it would probably make more sense to link nodes for node core modules to the node.js documentation.

I've made a (quick, very dirty, very non-configurable, not-yet-publishable) hack to gauge the possibilities - example output for the dot reporter (the hack works in other reporters as well) run against virtual-code-owners:

https://sverweij.github.io/examples/dependency-cruiser/links-to-different-targets.html

  • links npm (regular, dev, optional, peer, unknown) modules to https://www.npmjs.com/package/${packageName}
  • links node core modules to ~ https://nodejs.org/api/${pModule.source}.html

Questions

-> Would this work for you?
-> Would the hard coded URL prefixes for these be sufficient or would it need to be configurable?

@CaptainQuirk
Copy link
Author

Hi !

Well, that's exactly what I had in mind !

There may be a need for dynamic URL prefixes though: for example, I'm wondering how it would work with custom npm package registries. Gitlab has them.
For those particular packages, what would you link to ? Probably the source code. But, maybe the source code of such a dependency is hosted on a different git service than the main project.
What do you think ?

@CaptainQuirk
Copy link
Author

The hover feature on this example is great by the way !

@sverweij
Copy link
Owner

hmm yeah - configurable makes sense for alternative registries indeed (private or not). + they'll typically be mixed with the public packages from e.g. npmjs.

I thought to use fields from package.json (e.g. repository, homepage) but they're too inconsistent. they're not mandatory & nothing stops authors from filling out https://youtu.be/dQw4w9WgXcQ. Or worse.

I'll ponder some solutions to facilitate a split, but I guess as a first step having separate urls for core modules & npm modules would already be an improvement.

The hover feature on this example is great by the way !

Merci :-) It's the result of a little postprocessing on the generated svg - the script to do that is packaged with dependency-cruiser - see doc/cli.md#depcruise-wrap-stream-in-html if you also want to use it.

@CaptainQuirk
Copy link
Author

I agree with the first step approach ! Having links to the npm registry and the built-in node js module is sufficient for my use cases so far !

sverweij added a commit that referenced this issue Oct 20, 2023
…re modules (#854)

## Description

- for npm modules in the dot reporters link to npmjs.com
- for node modules link to nodejs.org

## Motivation and Context

Fixes #852 

## How Has This Been Tested?

- [x] green ci
- [x] additional automated integration tests

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation only change
- [ ] Refactor (non-breaking change which fixes an issue without
changing functionality)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
@sverweij
Copy link
Owner

@CaptainQuirk the (slightly cleaned up version) of the feature that has separate urls for core & npm modules has been shipped as part [email protected].

@CaptainQuirk
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants