aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-04-21 21:19:09 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-04-21 21:20:59 -1000
commit47a922112154cbc356eccd14c6e4f23ed668c322 (patch)
treeb76f150ee94afa75e242fabf82b2cc6018a8e6de
parentd4ebc65ac4f4a72c0ae1bd9cd5aa1fc7c7f5b22e (diff)
downloadpatchfoo-47a922112154cbc356eccd14c6e4f23ed668c322.tar.gz
patchfoo-47a922112154cbc356eccd14c6e4f23ed668c322.zip
Include ssb-npm
- Serve ssb-npm-registry requests under /npm-registry - Show install command for npm-packages messages
-rw-r--r--lib/app.js2
-rw-r--r--lib/render-msg.js12
-rw-r--r--lib/serve.js7
-rw-r--r--package-lock.json186
-rw-r--r--package.json1
5 files changed, 193 insertions, 15 deletions
diff --git a/lib/app.js b/lib/app.js
index cbbc74e..fbdbb8f 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -17,6 +17,7 @@ var proc = require('child_process')
var toPull = require('stream-to-pull-stream')
var BoxStream = require('pull-box-stream')
var crypto = require('crypto')
+var SsbNpmRegistry = require('ssb-npm-registry')
var zeros = new Buffer(24); zeros.fill(0)
@@ -65,6 +66,7 @@ function App(sbot, config) {
this.git = new Git(this.sbot, this.config)
this.contacts = new Contacts(this.sbot)
this.follows = new Follows(this.sbot, this.contacts)
+ this.serveSsbNpmRegistry = SsbNpmRegistry.respond(this.sbot, this.config)
this.monitorBlobWants()
}
diff --git a/lib/render-msg.js b/lib/render-msg.js
index b4ba87a..684ea40 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -1111,12 +1111,24 @@ RenderMsg.prototype.npmPackages = function (cb) {
function renderIdLink(id) {
return [h('a', {href: self.toUrl(id)}, truncate(id, 8)), ' ']
}
+ var singlePkg = self.c.mentions
+ && self.c.mentions.length === 1
+ && self.c.mentions[0]
+ var m = singlePkg && /^npm:(.*?):(.*?):/.exec(singlePkg.name)
+ var singlePkgSpec = m && (m[1] + (m[2] ? '@' + m[2] : ''))
self.render.npmPackageMentions(self.c.mentions, function (err, el) {
if (err) return cb(err)
var dependencyLinks = u.toArray(self.c.dependencyBranch)
var versionLinks = u.toArray(self.c.versionBranch)
self.wrap(h('div', [
el,
+ singlePkg ? h('p',
+ h('code',
+ 'npm install --registry=' +
+ 'http://' + self.app.host + ':' + self.app.port +
+ '/npm-registry/' + encodeURIComponent(self.msg.key) + ' ' +
+ singlePkgSpec),
+ ) : '',
dependencyLinks.length ? h('div',
'dependencies via: ', dependencyLinks.map(renderIdLink)
) : '',
diff --git a/lib/serve.js b/lib/serve.js
index 0e497ea..4b9eb1b 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -352,6 +352,7 @@ Serve.prototype.path = function (url) {
case '/npm': return this.npm(m[2])
case '/npm-prebuilds': return this.npmPrebuilds(m[2])
case '/npm-readme': return this.npmReadme(m[2])
+ case '/npm-registry': return this.npmRegistry(m[2])
case '/markdown': return this.markdown(m[2])
case '/zip': return this.zip(m[2])
case '/web': return this.web(m[2])
@@ -2534,6 +2535,12 @@ Serve.prototype.npmReadme = function (url) {
)
}
+Serve.prototype.npmRegistry = function (url) {
+ var self = this
+ self.req.url = url
+ self.app.serveSsbNpmRegistry(self.req, self.res)
+}
+
Serve.prototype.markdown = function (url) {
var self = this
var id = decodeURIComponent(url.substr(1))
diff --git a/package-lock.json b/package-lock.json
index 8533e05..0c2ed7f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "patchfoo",
- "version": "1.0.0",
+ "version": "1.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -195,11 +195,11 @@
},
"emoji-named-characters": {
"version": "http://localhost:8989/blobs/get/&vW38X+lwPDgAzgY6z6k6r2l7BiROggivH7F4lIUga0U=.sha256",
- "integrity": "sha1-zes20OZgAsS5178d+8Ohmft9QJs="
+ "integrity": "sha256-vW38X+lwPDgAzgY6z6k6r2l7BiROggivH7F4lIUga0U="
},
"emoji-server": {
"version": "http://localhost:8989/blobs/get/&Yt3cRdCu8ftMVwd+hBtgmrJ4ItRyrszK6Q5+qYTV8mw=.sha256",
- "integrity": "sha1-0GPP7prxGMxa7vvC6bPdUIWBXGM=",
+ "integrity": "sha256-Yt3cRdCu8ftMVwd+hBtgmrJ4ItRyrszK6Q5+qYTV8mw=",
"requires": {
"emoji-named-characters": "http://localhost:8989/blobs/get/&vW38X+lwPDgAzgY6z6k6r2l7BiROggivH7F4lIUga0U=.sha256"
}
@@ -292,11 +292,11 @@
},
"hashlru": {
"version": "http://localhost:8989/blobs/get/&EASZ1/L+jHuTVxrgbQrNlTdCenA8etAVuk/TGn92RoY=.sha256",
- "integrity": "sha1-eTpYlD+QKupXgXfXsDNfE/JpS3E="
+ "integrity": "sha256-EASZ1/L+jHuTVxrgbQrNlTdCenA8etAVuk/TGn92RoY="
},
"highlight.js": {
"version": "http://localhost:8989/blobs/get/&LK2T/oKc1S44QQjxG/3TDdR6OujGN7aWLR4It0ylTv4=.sha256",
- "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4="
+ "integrity": "sha256-LK2T/oKc1S44QQjxG/3TDdR6OujGN7aWLR4It0ylTv4="
},
"hosted-git-info": {
"version": "http://localhost:8989/blobs/get/&YUe3Q99bA5b/X94y+wiLwCspLENBKyIV4NuecamLnlE=.sha256",
@@ -517,7 +517,7 @@
},
"mime-types": {
"version": "http://localhost:8989/blobs/get/&bZmlnBs3fRBs4JRo1O8ArQGuTHxuKwk+vj9dI3OdvLY=.sha256",
- "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=",
+ "integrity": "sha256-bZmlnBs3fRBs4JRo1O8ArQGuTHxuKwk+vj9dI3OdvLY=",
"requires": {
"mime-db": "http://localhost:8989/blobs/get/&bthRei7RV8TfiQZxdmfGqc0N4W3c15dYuoEcDUFxyHY=.sha256"
},
@@ -788,8 +788,8 @@
"integrity": "sha1-CIew/7MK8ypW2+z6csFnInHwexM="
},
"pull-git-packidx-parser": {
- "version": "1.0.0",
- "resolved": "http://localhost:8989/blobs/get/&ou0MPQZabBgzrHDu54jzLU3Sc6Rf5a/lost0whPQUJ0=.sha256",
+ "version": "http://localhost:8989/blobs/get/&ou0MPQZabBgzrHDu54jzLU3Sc6Rf5a/lost0whPQUJ0=.sha256",
+ "integrity": "sha512-eV+5AHnj+BBnvidjLVPUczqKBlSnuiTeXh/4AXZN5iD5nkEin5sq7B7yfVoZLQbJs5zz9TQmmzH1Lpw9ApQEfw==",
"requires": {
"pull-stream": "3.6.1"
}
@@ -827,7 +827,7 @@
},
"pull-hyperscript": {
"version": "http://localhost:8989/blobs/get/&jMiBworh7lOvn5eH15aXOAVDHAJnsAVONJ3F6/+6lrg=.sha256",
- "integrity": "sha1-ykplgzYxhU9XWk4phVaMmQH1Y4M=",
+ "integrity": "sha256-jMiBworh7lOvn5eH15aXOAVDHAJnsAVONJ3F6/+6lrg=",
"requires": {
"pull-cat": "1.1.11",
"pull-stream": "3.6.1"
@@ -835,7 +835,7 @@
},
"pull-identify-filetype": {
"version": "http://localhost:8989/blobs/get/&+bhhz+qZR+p9Q93DusCRsOAMc3mhNU7f11DnnB3FLFo=.sha256",
- "integrity": "sha1-X5mvFeiEbUjs9iXtwkjsLPV/aw0=",
+ "integrity": "sha256-+bhhz+qZR+p9Q93DusCRsOAMc3mhNU7f11DnnB3FLFo=",
"requires": {
"pull-stream": "http://localhost:8989/blobs/get/&lilCQ+zOUuYxQdgWAG/nW1NGuFTlg0xJ0QhKwlJ7HWA=.sha256"
},
@@ -846,7 +846,7 @@
},
"pull-stream": {
"version": "http://localhost:8989/blobs/get/&lilCQ+zOUuYxQdgWAG/nW1NGuFTlg0xJ0QhKwlJ7HWA=.sha256",
- "integrity": "sha1-fql0E8FhnCC8O9+eEOkTR7AyU+Q=",
+ "integrity": "sha256-lilCQ+zOUuYxQdgWAG/nW1NGuFTlg0xJ0QhKwlJ7HWA=",
"requires": {
"pull-core": "http://localhost:8989/blobs/get/&HZk9i531Fe2BN93/439wkrzR5ItsqLTwkgOhYLs09ao=.sha256"
}
@@ -870,7 +870,7 @@
},
"pull-paginate": {
"version": "http://localhost:8989/blobs/get/&4gERPvcRCgSlKyybE+EiKHLIz4kbeSz5+T/MVAz0Jxo=.sha256",
- "integrity": "sha1-Y61Y76EGa8cBqlgamKPEHmrsf8I="
+ "integrity": "sha256-4gERPvcRCgSlKyybE+EiKHLIz4kbeSz5+T/MVAz0Jxo="
},
"pull-pair": {
"version": "1.1.0",
@@ -1211,7 +1211,7 @@
},
"ssb-contact": {
"version": "http://localhost:8989/blobs/get/&V4bNrv533a7pKfPxw7Ok92hNWBN+eCbyybmi8cGMzrM=.sha256",
- "integrity": "sha1-lGp4PIQOWRbVEsRTiJYQlwWQzWw=",
+ "integrity": "sha256-V4bNrv533a7pKfPxw7Ok92hNWBN+eCbyybmi8cGMzrM=",
"requires": {
"pull-defer": "http://localhost:8989/blobs/get/&mDI2o/JC9yvFOVbeAhDN+hwTm7cK+dBwISYO49EMY24=.sha256",
"pull-many": "http://localhost:8989/blobs/get/&wBHfPheBEjwjjkNoeM5mWtU/tYDs8+xnt5w6C1+EK3g=.sha256",
@@ -1227,7 +1227,7 @@
"hashlru": "http://localhost:8989/blobs/get/&EASZ1/L+jHuTVxrgbQrNlTdCenA8etAVuk/TGn92RoY=.sha256",
"looper": "4.0.0",
"multicb": "1.2.2",
- "pull-git-packidx-parser": "1.0.0",
+ "pull-git-packidx-parser": "http://localhost:8989/blobs/get/&ou0MPQZabBgzrHDu54jzLU3Sc6Rf5a/lost0whPQUJ0=.sha256",
"pull-kvdiff": "0.0.1",
"pull-paramap": "1.2.2",
"pull-reader": "1.2.9",
@@ -1247,7 +1247,7 @@
},
"ssb-marked": {
"version": "http://localhost:8989/blobs/get/&5yyYBZpB4w+X6kW42KMh43Xz9KP3XW79mYOj40/CHA4=.sha256",
- "integrity": "sha1-Fg4kETeCqcpegGByqnpl58hl2/I="
+ "integrity": "sha256-5yyYBZpB4w+X6kW42KMh43Xz9KP3XW79mYOj40/CHA4="
},
"ssb-mentions": {
"version": "http://localhost:8989/blobs/get/&GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256",
@@ -1273,6 +1273,147 @@
}
}
},
+ "ssb-npm-registry": {
+ "version": "1.8.0",
+ "resolved": "http://localhost:8989/blobs/get/&MbRjwEZANbSPO5kI5HflvJMRYj1hEYPj43OyXUN3fA8=.sha256",
+ "integrity": "sha256-MbRjwEZANbSPO5kI5HflvJMRYj1hEYPj43OyXUN3fA8=",
+ "requires": {
+ "asyncmemo": "1.0.0",
+ "hashlru": "2.2.0",
+ "multicb": "1.2.2",
+ "pull-cat": "1.1.11",
+ "pull-hash": "1.0.0",
+ "pull-stream": "3.6.1",
+ "semver": "5.4.1",
+ "stream-to-pull-stream": "1.7.2",
+ "tar-stream": "1.5.4"
+ },
+ "dependencies": {
+ "asyncmemo": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "bl": {
+ "version": "1.2.1",
+ "bundled": true,
+ "requires": {
+ "readable-stream": "2.3.3"
+ }
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "end-of-stream": {
+ "version": "1.4.0",
+ "bundled": true,
+ "requires": {
+ "once": "1.4.0"
+ }
+ },
+ "hashlru": {
+ "version": "2.2.0",
+ "bundled": true
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "bundled": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "looper": {
+ "version": "3.0.0",
+ "bundled": true
+ },
+ "multicb": {
+ "version": "1.2.2",
+ "bundled": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "bundled": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "bundled": true
+ },
+ "pull-cat": {
+ "version": "1.1.11",
+ "bundled": true
+ },
+ "pull-hash": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "pull-stream": {
+ "version": "3.6.1",
+ "bundled": true
+ },
+ "readable-stream": {
+ "version": "2.3.3",
+ "bundled": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "safe-buffer": "5.1.1",
+ "string_decoder": "1.0.3",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "bundled": true
+ },
+ "semver": {
+ "version": "5.4.1",
+ "bundled": true
+ },
+ "stream-to-pull-stream": {
+ "version": "1.7.2",
+ "bundled": true,
+ "requires": {
+ "looper": "3.0.0",
+ "pull-stream": "3.6.1"
+ }
+ },
+ "string_decoder": {
+ "version": "1.0.3",
+ "bundled": true,
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "tar-stream": {
+ "version": "1.5.4",
+ "bundled": true,
+ "requires": {
+ "bl": "1.2.1",
+ "end-of-stream": "1.4.0",
+ "readable-stream": "2.3.3",
+ "xtend": "4.0.1"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "xtend": {
+ "version": "4.0.1",
+ "bundled": true
+ }
+ }
+ },
"ssb-ref": {
"version": "http://localhost:8989/blobs/get/&wLimOD3785KVj7kBIAbjN6GH8EMhKRkcZSPrEMhdhks=.sha256",
"integrity": "sha1-XU7/xUXsD/1/wVuieCmmQLiir7o=",
@@ -1289,6 +1430,21 @@
"ssb-ref": "http://localhost:8989/blobs/get/&wLimOD3785KVj7kBIAbjN6GH8EMhKRkcZSPrEMhdhks=.sha256"
}
},
+ "ssb-web-resolver": {
+ "version": "1.1.2",
+ "resolved": "http://localhost:8989/blobs/get/&35PlGtKqmnuF8jqw2lF6KnXYJxzo+0+WVy1btqs1jU4=.sha256",
+ "integrity": "sha256-35PlGtKqmnuF8jqw2lF6KnXYJxzo+0+WVy1btqs1jU4=",
+ "requires": {
+ "pull-stream": "3.6.7"
+ },
+ "dependencies": {
+ "pull-stream": {
+ "version": "3.6.7",
+ "resolved": "http://localhost:8989/blobs/get/&vKpoExyiQaN73LOAI8K3oWMy8BNVF135RgRqZaliHLQ=.sha256",
+ "integrity": "sha256-vKpoExyiQaN73LOAI8K3oWMy8BNVF135RgRqZaliHLQ="
+ }
+ }
+ },
"stream-to-pull-stream": {
"version": "1.7.2",
"resolved": "http://localhost:8989/blobs/get/&djTfFg53BMgWrMVaCSww1ok8fAriwNnz0bsoj/MaZcI=.sha256",
diff --git a/package.json b/package.json
index 755a5ce..cb4dd2c 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
"ssb-mentions": "http://localhost:8989/blobs/get/&GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256",
"ssb-sort": "^1.0.0",
"ssb-web-resolver": "^1.0.2",
+ "ssb-npm-registry": "^1.8.0",
"stream-to-pull-stream": "^1.7.2",
"unzip": "^0.1.11"
},