Commit fa990c3c1bb26fac488d0440f044528ac4319647
include local sbot
Ev Bogue committed on 5/5/2018, 6:52:59 PMParent: ea39c986dd24cf5a10156a893292a9c4b5c66ba0
Files changed
package-lock.json | changed |
package.json | changed |
bin.js | added |
package-lock.json | ||
---|---|---|
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.json | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 … | }, |
10 | 10 … | "dependencies": { |
11 | 11 … | "cont": "^1.0.3", |
12 | 12 … | "dataurl-": "^0.1.0", |
13 … | + "decent-ssb": "^4.3.0", | |
13 | 14 … | "depject": "^4.1.1", |
14 | 15 … | "emoji-named-characters": "^1.0.2", |
15 | 16 … | "explain-error": "^1.0.4", |
16 | 17 … | "human-time": "0.0.1", |
@@ -20,33 +21,43 @@ | ||
20 | 21 … | "hyperlightbox": "^1.0.0", |
21 | 22 … | "hyperscript": "^2.0.2", |
22 | 23 … | "kvgraph": "^0.1.0", |
23 | 24 … | "map-filter-reduce": "^3.0.3", |
25 … | + "muxrpcli": "^1.1.0", | |
26 … | + "opn": "^5.3.0", | |
24 | 27 … | "pull-cat": "^1.1.11", |
25 | 28 … | "pull-many": "^1.0.8", |
26 | 29 … | "pull-next": "^1.0.1", |
27 | 30 … | "pull-paramap": "^1.2.2", |
28 | 31 … | "pull-reconnect": "^0.0.3", |
29 | 32 … | "pull-scroll": "^1.0.9", |
30 | 33 … | "pull-stream": "^3.6.1", |
34 … | + "pull-stringify": "^2.0.0", | |
35 … | + "scuttlebot": "^11.3.0", | |
31 | 36 … | "simple-mime": "^0.1.0", |
32 | 37 … | "split-buffer": "^1.0.0", |
33 | 38 … | "ssb-avatar": "^0.2.0", |
39 … | + "ssb-blobs": "^1.1.4", | |
34 | 40 … | "ssb-client": "^4.5.1", |
41 … | + "ssb-ebt": "^5.1.5", | |
35 | 42 … | "ssb-feed": "^2.3.0", |
43 … | + "ssb-friends": "^2.4.0", | |
36 | 44 … | "ssb-git": "^0.5.0", |
37 | 45 … | "ssb-keys": "^7.0.12", |
46 … | + "ssb-links": "^3.0.3", | |
38 | 47 … | "ssb-markdown": "^3.3.0", |
39 | 48 … | "ssb-mentions": "^0.4.1", |
49 … | + "ssb-query": "^2.0.1", | |
40 | 50 … | "ssb-ref": "^2.7.1", |
41 | 51 … | "ssb-sort": "^1.0.0", |
42 | 52 … | "suggest-box": "^2.2.3", |
43 | 53 … | "text-node-searcher": "^1.1.1", |
44 | - "visualize-buffer": "0.0.1" | |
54 … | + "visualize-buffer": "0.0.1", | |
55 … | + "yargs": "^11.0.0" | |
45 | 56 … | }, |
46 | 57 … | "scripts": { |
47 | 58 … | "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" | |
49 | 60 … | }, |
50 | 61 … | "author": "Everett Bogue <ev@evbogue.com> (http://evbogue.com)", |
51 | 62 … | "license": "MIT", |
52 | 63 … | "devDependencies": { |
bin.js | ||
---|---|---|
@@ -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