-
-
Notifications
You must be signed in to change notification settings - Fork 32
feat: pages for npm cached packages #164
base: master
Are you sure you want to change the base?
feat: pages for npm cached packages #164
Conversation
| "./node_modules/@types" | ||
| ] | ||
| ], | ||
| "experimentalDecorators": true |
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 think, we should not use experimental stuff.
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 added this line to allow MSVC to use decorators (as https://ihatetomatoes.net/how-to-remove-experimentaldecorators-warning-in-vscode/ says).
Do not know why they call it "experimental" as decorators was added many years ago.
Looks like this thing is not very experimental and we can use it.
src/utils.ts
Outdated
| const versions = await getVersions(scopePath, scopedDirName); | ||
| // list content of such directory | ||
| listPackages[`${directory}/${scopedDirName}`] = //{ | ||
| // path: scopePath, |
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.
Commented code can be removed 😃
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.
Fixed
src/utils.ts
Outdated
| async function getVersions(scopePath: string, packageName: string): Promise<string[]> { | ||
| const versions: string[] = []; | ||
| const arr: string[] = await readDirectory(scopePath); | ||
| arr.forEach( (filePath: string) => { |
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 would suggest to use reduce.
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.
Fixed: cannot imagine how to use reduce here, but I changed it to use filter and map.
src/utils.ts
Outdated
| export async function findPackages(storagePath: string) { | ||
| //stats | ||
| const startTS = Date.now(); | ||
| let packages_count = 0; |
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 use camelCase format for consistency.
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.
Fixed
ayusharma
left a comment
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.
Thanks for the PR @artemdudkin, there are some improvements.
|
Any thoughts? |
|
No yet, on my queue. |
Type:
PoC version for task "Pages for npm cached packages"
(verdaccio/verdaccio#706)
Description:
This is simple implementation (with simple 1-minute-timeout cache) of service that returns list of cached packages including version numbers of cached packages (i.e. it iterate through "storage" folder).