rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[lockfile-explorer]Add version validation capability

Open L-Qun opened this issue 9 months ago • 4 comments

Summary

Our team currently has a requirement to analyze whether the dependency tree contains multiple versions of a target package, so I have implemented this feature into lockfile-explorer.

Details

In this PR, I have introduced an additional dependency on yargs to parse arguments and expanded the capabilities of lockfile-explorer, enabling it to function as a CLI tool to check if there are multiple versions of a target package.

The previous default behavior of lockfile-explorer has been changed to:

lockfile-explorer --> lockfile-explorer start lockfile-explorer --subspace xxx --> lockfile-explorer start --subspace xxx

Additionally, new capabilities have been extended, the usage is:

lockfile-explorer check react lockfile-explorer check --project xxx react lockfile-explorer check --project xxx react@18 lockfile-explorer check --project xxx [email protected] lockfile-explorer check --project xxx [email protected]

How it was tested

Manually tested with Rushstack repo locally.

Impacted documentation

@william2958

L-Qun avatar May 15 '24 14:05 L-Qun

image

The website will definitely need to be updated to document this CLI

octogonz avatar May 17 '24 21:05 octogonz

Our team currently has a requirement to analyze whether the dependency tree contains multiple versions of a target package, so I have implemented this feature into lockfile-explorer.

@L-Qun This sounds somewhat related to the earlier Design Proposal: Lockfile Lint which @william2958 prototyped in https://github.com/microsoft/rushstack/pull/4094

🤔 Besides checking "Does this project's dependency tree include multiple copies of react?", it's easy to imagine lots of other problems that could be detected with similar "checks."

And the UX has several possible approaches:

  1. Web app: The checks can be performed via commands in the Lockfile Explorer web app
  2. Manually invoked shell command: The checks can be performed by invoking a CLI like lockfile-explorer check
  3. Lockfile Lint: The checks could be defined/customized in JSON config files, and then enforced automatically by a CI pipeline.

(In fact, it would be possible to provide all 3 approaches for each check.)

So your PR seems like a good idea, but I wonder if it maybe it could be a bit more flexible, or build on the Lockfile Lint design.

octogonz avatar May 17 '24 21:05 octogonz

image

The website will definitely need to be updated to document this CLI

Do you mean to update the content here? https://github.com/microsoft/rushstack-websites/blob/main/websites/lfx.rushstack.io/docs

L-Qun avatar May 19 '24 12:05 L-Qun

Our team currently has a requirement to analyze whether the dependency tree contains multiple versions of a target package, so I have implemented this feature into lockfile-explorer.

@L-Qun This sounds somewhat related to the earlier Design Proposal: Lockfile Lint which @william2958 prototyped in #4094

🤔 Besides checking "Does this project's dependency tree include multiple copies of react?", it's easy to imagine lots of other problems that could be detected with similar "checks."

And the UX has several possible approaches:

  1. Web app: The checks can be performed via commands in the Lockfile Explorer web app
  2. Manually invoked shell command: The checks can be performed by invoking a CLI like lockfile-explorer check
  3. Lockfile Lint: The checks could be defined/customized in JSON config files, and then enforced automatically by a CI pipeline.

(In fact, it would be possible to provide all 3 approaches for each check.)

So your PR seems like a good idea, but I wonder if it maybe it could be a bit more flexible, or build on the Lockfile Lint design.

I think making the lockfile-explorer tool better is a long-term process. Perhaps we can first merge this PR after I update the documentation, and then I will gradually iterate and optimize it.

L-Qun avatar May 19 '24 12:05 L-Qun

This PR was accidentally merged when I pushed to origin instead of the forked repo. Reopened via https://github.com/microsoft/rushstack/pull/4779

octogonz avatar Jun 12 '24 05:06 octogonz

The website will definitely need to be updated to document this CLI

Do you mean to update the content here? https://github.com/microsoft/rushstack-websites/blob/main/websites/lfx.rushstack.io/docs

Yes, I can help with this. 👍

octogonz avatar Jun 12 '24 05:06 octogonz