git ssb

0+

ev / minbase



Commit fa990c3c1bb26fac488d0440f044528ac4319647

include local sbot

Ev Bogue committed on 5/5/2018, 6:52:59 PM
Parent: ea39c986dd24cf5a10156a893292a9c4b5c66ba0

Files changed

package-lock.jsonchanged
package.jsonchanged
bin.jsadded
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 78527 bytes
New file size: 206300 bytes
package.jsonView
@@ -9,8 +9,9 @@
99 },
1010 "dependencies": {
1111 "cont": "^1.0.3",
1212 "dataurl-": "^0.1.0",
13 + "decent-ssb": "^4.3.0",
1314 "depject": "^4.1.1",
1415 "emoji-named-characters": "^1.0.2",
1516 "explain-error": "^1.0.4",
1617 "human-time": "0.0.1",
@@ -20,33 +21,43 @@
2021 "hyperlightbox": "^1.0.0",
2122 "hyperscript": "^2.0.2",
2223 "kvgraph": "^0.1.0",
2324 "map-filter-reduce": "^3.0.3",
25 + "muxrpcli": "^1.1.0",
26 + "opn": "^5.3.0",
2427 "pull-cat": "^1.1.11",
2528 "pull-many": "^1.0.8",
2629 "pull-next": "^1.0.1",
2730 "pull-paramap": "^1.2.2",
2831 "pull-reconnect": "^0.0.3",
2932 "pull-scroll": "^1.0.9",
3033 "pull-stream": "^3.6.1",
34 + "pull-stringify": "^2.0.0",
35 + "scuttlebot": "^11.3.0",
3136 "simple-mime": "^0.1.0",
3237 "split-buffer": "^1.0.0",
3338 "ssb-avatar": "^0.2.0",
39 + "ssb-blobs": "^1.1.4",
3440 "ssb-client": "^4.5.1",
41 + "ssb-ebt": "^5.1.5",
3542 "ssb-feed": "^2.3.0",
43 + "ssb-friends": "^2.4.0",
3644 "ssb-git": "^0.5.0",
3745 "ssb-keys": "^7.0.12",
46 + "ssb-links": "^3.0.3",
3847 "ssb-markdown": "^3.3.0",
3948 "ssb-mentions": "^0.4.1",
49 + "ssb-query": "^2.0.1",
4050 "ssb-ref": "^2.7.1",
4151 "ssb-sort": "^1.0.0",
4252 "suggest-box": "^2.2.3",
4353 "text-node-searcher": "^1.1.1",
44- "visualize-buffer": "0.0.1"
54 + "visualize-buffer": "0.0.1",
55 + "yargs": "^11.0.0"
4556 },
4657 "scripts": {
4758 "build": "node scripts/style.js && mkdir -p build && browserify index.js | indexhtmlify > build/index.html",
48- "start": "node serve.js"
59 + "start": "node bin server"
4960 },
5061 "author": "Everett Bogue <ev@evbogue.com> (http://evbogue.com)",
5162 "license": "MIT",
5263 "devDependencies": {
bin.jsView
@@ -1,0 +1,107 @@
1 +var fs = require('fs')
2 +var path = require('path')
3 +var ssbKeys = require('ssb-keys')
4 +var stringify = require('pull-stringify')
5 +var yargs = require('yargs').argv
6 +var open = require('opn')
7 +var muxrpcli = require('muxrpcli')
8 +
9 +var config = require('decent-ssb/config/inject')(yargs.appname || 'decent')
10 +
11 +config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
12 +
13 +var manifestFile = path.join(config.path, 'manifest.json')
14 +
15 +var decentClient = fs.readFileSync(path.join('./build/index.html'))
16 +
17 +var argv = process.argv.slice(2)
18 +var i = argv.indexOf('--')
19 +var conf = argv.slice(i+1)
20 +argv = ~i ? argv.slice(0, i) : argv
21 +
22 +if (argv[0] == 'server') {
23 + var createSbot = require('scuttlebot')
24 + .use(require('scuttlebot/plugins/master'))
25 + .use(require('scuttlebot/plugins/gossip'))
26 + .use(require('scuttlebot/plugins/replicate'))
27 + .use(require('ssb-friends'))
28 + .use(require('ssb-blobs'))
29 + .use(require('ssb-query'))
30 + .use(require('ssb-links'))
31 + .use(require('ssb-ebt'))
32 + .use(require('scuttlebot/plugins/invite'))
33 + .use(require('scuttlebot/plugins/local'))
34 + .use(require('decent-ssb/plugins/ws'))
35 + .use({
36 + name: 'serve',
37 + version: '1.0.0',
38 + init: function (sbot) {
39 + sbot.ws.use(function (req, res, next) {
40 + var send = {}
41 + send = config
42 + delete send.keys
43 + send.address = sbot.ws.getAddress()
44 + if(req.url == '/')
45 + res.end(decentClient)
46 + if(req.url == '/get-config')
47 + res.end(JSON.stringify(send))
48 + else next()
49 + })
50 + }
51 + })
52 +
53 + open('http://localhost:' + config.ws.port, {wait: false})
54 +
55 + var server = createSbot(config)
56 +
57 + fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2))
58 +
59 +} else {
60 +
61 + var manifest
62 + try {
63 + manifest = JSON.parse(fs.readFileSync(manifestFile))
64 + } catch (err) {
65 + throw explain(err,
66 + 'no manifest file'
67 + + '- should be generated first time server is run'
68 + )
69 + }
70 +
71 + // connect
72 + require('ssb-client')(config.keys, {
73 + manifest: manifest,
74 + port: config.port,
75 + host: config.host||'localhost',
76 + caps: config.caps,
77 + key: config.key || config.keys.id
78 + }, function (err, rpc) {
79 + if(err) {
80 + if (/could not connect/.test(err.message)) {
81 + console.log('Error: Could not connect to the scuttlebot server.')
82 + console.log('Use the "server" command to start it.')
83 + if(config.verbose) throw err
84 + process.exit(1)
85 + }
86 + throw err
87 + }
88 +
89 + // add some extra commands
90 + manifest.version = 'async'
91 + manifest.config = 'sync'
92 + rpc.version = function (cb) {
93 + console.log(require('./package.json').version)
94 + cb()
95 + }
96 + rpc.config = function (cb) {
97 + console.log(JSON.stringify(config, null, 2))
98 + cb()
99 + }
100 +
101 + // run commandline flow
102 + muxrpcli(argv, manifest, rpc, config.verbose)
103 + })
104 +}
105 +
106 +
107 +

Built with git-ssb-web