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

add offline mode - only look at cache #49

Closed
dylang opened this Issue Jun 6, 2014 · 10 comments

Comments

Projects
None yet
4 participants
@dylang

dylang commented Jun 6, 2014

This is great for those times you are working on a plane (me in a few hours, i better get some sleep), or your favorite npm registry is inaccessible (because I'm too tired to get on the vpn).

I've tried forcing it via options, but stuff like this:
https://github.com/npm/npm-registry-client/blob/master/lib/request.js#L118-L121
causes the client to use the coded defaults when we try to get it to use falsey values.

Not that I ever want to copy features from Maven, but it was nice that you could easily ignore the registry with the -o option, and have it just use your local cache.

@othiym23

This comment has been minimized.

Show comment
Hide comment
@othiym23

othiym23 Jun 6, 2014

Contributor

I'm sorry, I'm not sure I understand what you're getting at here. Is this a feature request? The code you link to hasn't changed for a couple years now.

Ideally, the registry client wouldn't know anything about the cache at all, and the cache would be managed by another module, with npm itself acting as the orchestrator. In that world, the client would just be handing metadata, blobs or streams back to npm, so it should be possible to mock out the client altogether. Do you have something else in mind?

Contributor

othiym23 commented Jun 6, 2014

I'm sorry, I'm not sure I understand what you're getting at here. Is this a feature request? The code you link to hasn't changed for a couple years now.

Ideally, the registry client wouldn't know anything about the cache at all, and the cache would be managed by another module, with npm itself acting as the orchestrator. In that world, the client would just be handing metadata, blobs or streams back to npm, so it should be possible to mock out the client altogether. Do you have something else in mind?

@dylang dylang changed the title from offline mode - only look at cache to [feat req] offline mode - only look at cache Jun 6, 2014

@dylang

This comment has been minimized.

Show comment
Hide comment
@dylang

dylang Jun 6, 2014

yup, late in the day feature request. I changed the title to reflect that.

with npm itself acting as the orchestrator

I'm not sure if I agree. I'm not using npm for the project I'm creating. That seems too high level for my needs. I just need <package-name>/latest, using the users' active npmrc settings.

This project has a stale option:

If there's cached data available, then return that to the callback quickly, and update the cache the background.

I basically want that, but without the attempt to update the cache in the background.

If we ever add an offline feature to npm, I think it would pass to this client's options {offline: true}.

dylang commented Jun 6, 2014

yup, late in the day feature request. I changed the title to reflect that.

with npm itself acting as the orchestrator

I'm not sure if I agree. I'm not using npm for the project I'm creating. That seems too high level for my needs. I just need <package-name>/latest, using the users' active npmrc settings.

This project has a stale option:

If there's cached data available, then return that to the callback quickly, and update the cache the background.

I basically want that, but without the attempt to update the cache in the background.

If we ever add an offline feature to npm, I think it would pass to this client's options {offline: true}.

@othiym23

This comment has been minimized.

Show comment
Hide comment
@othiym23

othiym23 Jun 6, 2014

Contributor

Unless I'm missing something obvious (which is possible, because a lot of this code and its supporting design decisions are still new to me), when you're offline, you're just going to be interacting with what's available in the cache. What is there for the client to do when there's no registry to talk to?

Contributor

othiym23 commented Jun 6, 2014

Unless I'm missing something obvious (which is possible, because a lot of this code and its supporting design decisions are still new to me), when you're offline, you're just going to be interacting with what's available in the cache. What is there for the client to do when there's no registry to talk to?

@othiym23 othiym23 added the enhancement label Jun 6, 2014

@othiym23 othiym23 changed the title from [feat req] offline mode - only look at cache to add offline mode - only look at cache Jun 6, 2014

@dylang

This comment has been minimized.

Show comment
Hide comment
@dylang

dylang Jun 6, 2014

When you are offline, npm-registry-client sits there painfully timing out and retrying, partially because of the above mentioned defaults.

The proposed offline option would skip that and just use whatever is in cache.

this code and its supporting design decisions are still new to me

haha, I have such a love/hate relation with Isaac's npm code, and I praise you as a developer god and patient saint for improving his code.

dylang commented Jun 6, 2014

When you are offline, npm-registry-client sits there painfully timing out and retrying, partially because of the above mentioned defaults.

The proposed offline option would skip that and just use whatever is in cache.

this code and its supporting design decisions are still new to me

haha, I have such a love/hate relation with Isaac's npm code, and I praise you as a developer god and patient saint for improving his code.

@othiym23

This comment has been minimized.

Show comment
Hide comment
@othiym23

othiym23 Jun 6, 2014

Contributor

So why wouldn't your program also depend on the putative npm-cache and implement the offline mode itself? I really would, if possible, like for npm-registry-client to have as its sole concern doing stuff on the registry. It seems strange to me to have it be aware of the cache at all.

Contributor

othiym23 commented Jun 6, 2014

So why wouldn't your program also depend on the putative npm-cache and implement the offline mode itself? I really would, if possible, like for npm-registry-client to have as its sole concern doing stuff on the registry. It seems strange to me to have it be aware of the cache at all.

@dylang

This comment has been minimized.

Show comment
Hide comment
@dylang

dylang Jun 6, 2014

So why wouldn't your program also depend on the putative npm-cache

What's that?

It seems strange to me to have it be aware of the cache at all.

Maybe you are picturing the design changing, but currently cache is the only required parameter to use npm-registry-client.

I think of the local cache as "another" registry, but read only.

dylang commented Jun 6, 2014

So why wouldn't your program also depend on the putative npm-cache

What's that?

It seems strange to me to have it be aware of the cache at all.

Maybe you are picturing the design changing, but currently cache is the only required parameter to use npm-registry-client.

I think of the local cache as "another" registry, but read only.

@calvinmetcalf

This comment has been minimized.

Show comment
Hide comment

calvinmetcalf commented Aug 11, 2014

@othiym23

This comment has been minimized.

Show comment
Hide comment
@othiym23

othiym23 Aug 11, 2014

Contributor

Yeah, I think local-npm is pretty close to what you're describe, @dylang, but that's not the direction npm itself is headed at all. Look at the work I did when integrating fetch into npm-registry-client – it passes the stream back to the caller, and makes dealing with where to put the fetched package blob the caller's problem. Once npm-cache is a little further along, I'll put up a blog post showing how it and npm-registry-client are made to communicate with each other indirectly via the CLI.

Contributor

othiym23 commented Aug 11, 2014

Yeah, I think local-npm is pretty close to what you're describe, @dylang, but that's not the direction npm itself is headed at all. Look at the work I did when integrating fetch into npm-registry-client – it passes the stream back to the caller, and makes dealing with where to put the fetched package blob the caller's problem. Once npm-cache is a little further along, I'll put up a blog post showing how it and npm-registry-client are made to communicate with each other indirectly via the CLI.

@dylang

This comment has been minimized.

Show comment
Hide comment
@dylang

dylang Aug 12, 2014

@othiym23 I think I you said what I wanted to hear in the latest Nodeup podcast in reference to splitting npm-cache module out. Thanks for doing that interview!

I'm fine closing this issue since it sounds like you have this planned already.

dylang commented Aug 12, 2014

@othiym23 I think I you said what I wanted to hear in the latest Nodeup podcast in reference to splitting npm-cache module out. Thanks for doing that interview!

I'm fine closing this issue since it sounds like you have this planned already.

@isaacs

This comment has been minimized.

Show comment
Hide comment
@isaacs

isaacs Aug 23, 2014

Member

Use-case will be handled in a different way. Thanks!

Member

isaacs commented Aug 23, 2014

Use-case will be handled in a different way. Thanks!

@isaacs isaacs closed this Aug 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment