-
Notifications
You must be signed in to change notification settings - Fork 189
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
Set up back end to recollect information from pnpm #2797
Conversation
I notice a few Eslint issues, fix them first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a great way to do it. The dependencies list and their information can be extracted using pnpm list and pnpm view cli, and we can use child_process.exec
or other libraries to call the cli.
For example
const { exec } = require('child_process');
exec("pnpm list --dep 2 --json", (error, stdout) => {
stdout.forEach((dep) => {
exec(`pnpm view ${dep} repository.url`")
})
})
That's untested code but should give you some idea, hope that helps.
See
https://docs.npmjs.com/cli/v7/commands/npm-view
https://pnpm.io/cli/list
So, the only problem with So, if that won't make the image or the container super big, then I can switch it to that approach. Could someone that knows more about Docker let me know if this is true? |
Yes, this will complicate things. I think we're going to have to add a script in So maybe focus on writing a node.js script in @manekenpix might have a better idea. |
So, this was similar to the first approach I wanted to go with. Let me pitch it first. The first approach was creating a tool that produces a file similar to The only problem I would see with the aforementioned approach is that there is too much separation between two components that I feel should be together 😞 The current code is like a weird amalgamation between the approach I mentioned and the current one I had. |
Is it possible to run I would love it to also display a flat list just like how |
You just need to specify a depth, and it will do deps of deps. |
From the discussion in the pnpm repo, it seems I can specify One small clarification: do we want to lump all dependencies and say they are part of Telescope, instead of dividing them into the microservices projects? If we do it with the json/parseable way, we will have to group all dependencies this way |
When I tried running it with any depth over 5, it returned one billion responses and took forever. I'm not sure that we have to go that deep? I don't think we care which part of Telescope uses them, or whether they are a direct or indirect dep. We just want to figure out where to look for things to work on. |
I think if you ran it with I had the intention to collect all dependencies of Telescope, and the easy way was by going through the |
Pipe the output through ❯ pnpm list --parseable --depth 5 | wc -l
97762
❯ pnpm list --parseable --depth 5 | uniq | wc -l
2466
~/repos/telescope sso-dockerfile-fix |
164d8a4
to
2693080
Compare
2693080
to
aee5670
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to need to Dockerize this as well, and figure out the logic for calling your script at build-time when we deploy in a follow-up.
But I think this gives us a beginning worth having.
@@ -0,0 +1,24 @@ | |||
#!/bin/bash | |||
|
|||
# First regex can be read as the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯🤯🤯🤯🤯
31c43c2
to
addf033
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor nits.
// The order of the alternatives is important! | ||
// The regex engine will favor the first pattern on an alternation | ||
// even if the other alternatives are subpatterns | ||
return dependencies.split(/\r\n|\n|\r/).filter((line) => line !== ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty typical to do /\r?\n/
to deal with Unix vs. Windows, but this is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 1 nit: you can chain sed expressions
addf033
to
246e9d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'll file follow-up issues on things I notice that still need to happen.
Issue This PR Addresses
Fixes #2738
Type of Change
Description
The service offers a single route:
/projects
, where it returns a list of all project names that Telescope depends on. The service uses a text file to load this information. The file is nameddeps.txt
. The one I have copied there is for testing purposes, so that you don't have to run the tool if you can't.The tool that generates this file is a one-line
bash
script, which callspnpm list
and does some stream processing to reduce the information needed. The tool can be found in thetools
folder. Since this is abash
script, Windows users cannot test it. A PowerShell script may be necessary.Steps to test the PR
As of right now, this service is not integrated completely with Docker. To start it up, you have to do the following:
pnpm install
to get all dependenciessrc/api/dependency-graph
folderpnpm start
to start up the applicationChecklist