npm/npm — pull request #6208 by luckysw (2014-09-17 08:00:02+00:00)
Title: - Improved "outdated" command to update remote tarballs when the remote content changes

Hi,
We are working with some remote tarballs, referred using its direct http/https URL in the dependency/devDependencies list.
We found that npm caches the content of that tarball using the URL as unique key.
This is absolutely fine for "tagged" release that never changes. However if we want to support a snapshot-like based deployment (in our continous-integration environment), we would like to release "-SNAPSHOT" remote tarballs, where a CI build machine pushes new content in that tarballs at each build.

Simply using "npm cache clean " doesn't work, since the command cleans the local cache, but not the "node_modules" local folder.

So I've tried to enhance npm with the minimum set of changes, in order to make the "outdated" command to actively check the remote repos.
Changes:

- the local 'package.json' is enriched with a new property (_remote) containing some useful information about the GET response headers (currently etag and modification date), with the original URL as well.
- added new file 'check-remote-tarballs' with the logic to issue a HEAD request
- added new file 'remote-options' with the logic to issue the HEAD request with the right headers, in order to stimulate the HTTP 304 (Not Modified) response.

As a side note, I've found that the "add-remote-tarball" actually uses the npm registry API to issue the GET command for a remote tarball. Is that intended? The npm registry module adds logic to support registry authentication, ca, session, etc... that are actually useless if the remote tarball is on a non-registry machine.
In addition, we needed to patch our IIS server to server .tgz files with the non-standard MIME type "application/x-tar" (explicitly required by npm registry module).
The added HEAD support cannot use the npm registry module (unless we add the HEAD support there), so I've directly used the 'request' dependency.

Thank you for this great tool!
Luciano