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

feat: pages for npm cached packages#164

Open
artemdudkin wants to merge 2 commits into
verdaccio:masterfrom
artemdudkin:issue-706-cached-packages
Open

feat: pages for npm cached packages#164
artemdudkin wants to merge 2 commits into
verdaccio:masterfrom
artemdudkin:issue-706-cached-packages

Conversation

@artemdudkin

Copy link
Copy Markdown

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

Comment thread tsconfig.json
"./node_modules/@types"
]
],
"experimentalDecorators": true

Copy link
Copy Markdown
Contributor

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.

@artemdudkin artemdudkin Apr 29, 2019

Copy link
Copy Markdown
Author

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.

Comment thread src/utils.ts Outdated
const versions = await getVersions(scopePath, scopedDirName);
// list content of such directory
listPackages[`${directory}/${scopedDirName}`] = //{
// path: scopePath,

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread 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) => {

@ayusharma ayusharma Apr 29, 2019

Copy link
Copy Markdown
Contributor

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.

@artemdudkin artemdudkin Apr 29, 2019

Copy link
Copy Markdown
Author

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.

Comment thread src/utils.ts Outdated
export async function findPackages(storagePath: string) {
//stats
const startTS = Date.now();
let packages_count = 0;

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

@ayusharma ayusharma left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Author

Any thoughts?

@juanpicado

Copy link
Copy Markdown
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