Skip to content
This repository has been archived by the owner on Aug 16, 2019. It is now read-only.

feat: pages for npm cached packages #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

artemdudkin
Copy link

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).

@@ -11,7 +11,8 @@
"typeRoots": [
"./node_modules/@verdaccio/types/lib/verdaccio",
"./node_modules/@types"
]
],
"experimentalDecorators": true
Copy link
Member

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.

Copy link
Author

@artemdudkin artemdudkin Apr 29, 2019

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,
Copy link
Member

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 😃

Copy link
Author

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) => {
Copy link
Member

@ayusharma ayusharma Apr 29, 2019

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.

Copy link
Author

@artemdudkin artemdudkin Apr 29, 2019

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;
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

@ayusharma ayusharma left a 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.

@artemdudkin
Copy link
Author

Any thoughts?

@juanpicado
Copy link
Member

No yet, on my queue.

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

Successfully merging this pull request may close these issues.

3 participants