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

fix: detect yarn.lock files in bin command #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

candrews
Copy link

@candrews candrews commented Sep 22, 2022

What this does

In the bin command, detect yarn.lock files in addition to the existing support for package.json and package-lock.json.

Notes for the reviewer

node bin/index.js from a directory containing a yarn.lock file now display results.

More information

Screenshots

Visuals that may help the reviewer

@candrews candrews requested a review from a team as a code owner September 22, 2022 20:02
@candrews candrews requested review from klesniewski and orsagie and removed request for a team September 22, 2022 20:02
@CLAassistant
Copy link

CLAassistant commented Sep 22, 2022

CLA assistant check
All committers have signed the CLA.

xzhou-snyk
xzhou-snyk previously approved these changes Oct 12, 2022
@xzhou-snyk xzhou-snyk self-requested a review October 12, 2022 11:20
@JamesPatrickGill
Copy link
Member

Hi @candrews, thanks for this PR! I'll be looking after this PR and helping you get it released.

Firstly due to our internal systems requiring a non fork branch to run CI could you please first point this PR at this branch detect-yarn-lock-in-bin-cmd. This will allow me to run tests before deploying it and hence merge your PR safely.

In the meantime I will look over the PR.

Thanks again 😃

Copy link
Member

@JamesPatrickGill JamesPatrickGill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added some pointers to help you reach what I believe the goal of the ticket is. Hope these are helpful 😃

As an aside, could you please share how you are using this binary to help maybe mold the solution.

Many thanks again for this PR 🙏

@@ -1,7 +1,7 @@
#!/usr/bin/env node
const inspect = require('../dist/index')

inspect.buildDepTreeFromFiles('./', 'package.json', 'package-lock.json')
inspect.buildDepTreeFromFiles('./', 'package.json', 'package-lock.json', 'yarn.lock')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I don't believe this code works as you expect.

To illustrate, here is the function signature for this function

function buildDepTreeFromFiles(
    root: string, 
    manifestFilePath: string, 
    lockFilePath: string, 
    includeDev?: boolean, 
    strictOutOfSync?: boolean
): Promise<PkgTree>

This would mean we are passing yarn.lock to the includeDev argument.

I would suggest updating so that the 3rd argument - lockFilePath - is conditionally passed as package-lock.json or yarn.lock based on some trigger. Maybe an cli flag as this is a "bin".

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

Successfully merging this pull request may close these issues.

None yet

4 participants