Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dshaw/3180050 to your computer and use it in GitHub Desktop.
Save dshaw/3180050 to your computer and use it in GitHub Desktop.
private npm repo namespace idea so that private registries don't have to replicate the entire public NPM registry or you don't have to do some sort of conditional proxying.
// A module published to a private registry would optionally have a "registry"
// property that is a reference to the registry where this module is published.
//
// A `npm publish` would publish to the registry in the registry property.
//
// Otherwise, `npm --registry http://private.me:5984/registry/_design/app/_rewrite publish`
//
{
"name": "foo",
"description": "a module published to a private registry",
"version": "1.0.1",
"dependencies": {},
"registry": "http://private.me:5984/registry/_design/app/_rewrite"
}
// If this module, `with-some-privates` depends on modules from a private registry (could be public too),
// it can register module namespaces that will be used when resolving dependencies by specifying the
// namespace and the URL of the registry in the `registries` property.
//
// The namespaces are meaningless outside of this package.json, they are simply and alias to the registry
// for dependencies.
//
// Dependencies would reference modules in the private registry by the namespace prefix and some delimiter,
// a hash (`#`) perhaps.
//
// After installing the module you could require it without the namespace like
// `require('foo') --- possible conflicts, but simplifies other things (?)
//
{
"name": "with-some-privates",
"description": "a module with private registry references",
"version": "0.2.0",
"dependencies": {
"request": "2.9.x",
"myprivates#foo": "1.0.1",
"another#bar": "0.2.0"
},
registries: {
"myprivates": "http://private.me:5984/registry/_design/app/_rewrite",
"another": "http://another.com:5984/registry/_design/app/_rewrite"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment