Browse Source

remove cli

Kieran Gibb 1 year ago
parent
commit
72eddb2914
No known key found for this signature in database

+ 0
- 10
cobox-cli/bin/groups.js View File

@@ -1,10 +0,0 @@
1
-exports.command = 'groups'
2
-exports.desc = 'create, join, leave and mount'
3
-exports.builder = function (yargs) {
4
-  return yargs
5
-    .commandDir('groups')
6
-    .demandCommand()
7
-    .help()
8
-    .argv
9
-}
10
-exports.handler = function (argv) {}

+ 0
- 54
cobox-cli/bin/groups/create.js View File

@@ -1,54 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'create'
13
-exports.desc = 'create a new group'
14
-exports.builder = {
15
-  name: {
16
-    description: 'the name of the group',
17
-    type: 'string',
18
-    alias: 'n',
19
-    demandOption: true
20
-  },
21
-  address: {
22
-    description: 'the address of the group',
23
-    type: 'string',
24
-    alias: 'A'
25
-  },
26
-  encryptionKey: {
27
-    description: 'the encryption key of the group',
28
-    type: 'string',
29
-    alias: 'k'
30
-  }
31
-}
32
-exports.handler = async function (argv) {
33
-  var name = argv.name,
34
-    address = argv.address,
35
-    encryptionKey = argv.encryptionKey,
36
-    response,
37
-    group
38
-
39
-  var data = { name, address, encryptionKey }
40
-
41
-  onSuccess('creating a new group...')
42
-
43
-  try {
44
-    response = await request.post(`/groups`, data)
45
-    group = response.data
46
-  } catch (error) {
47
-    response = error.response
48
-    var errors = response.data.errors
49
-    return onError(errors.map((err) => err.msg))
50
-  }
51
-
52
-  onSuccess(`successfully created ${name}`)
53
-  printGroups(group)
54
-}

+ 0
- 46
cobox-cli/bin/groups/drive.js View File

@@ -1,46 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'drive'
13
-exports.desc = 'get drive history'
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address of the group',
17
-    type: 'string',
18
-    alias: 'A'
19
-  },
20
-  name: {
21
-    description: 'the name of the group',
22
-    type: 'string',
23
-    alias: 'n',
24
-    demandOption: true
25
-  }
26
-}
27
-exports.handler = async function (argv) {
28
-  let address = argv.address,
29
-    name = argv.name,
30
-    id = argv.address || argv.name
31
-
32
-  var data = { name, address }
33
-
34
-  try {
35
-    var response = await request.get(`/groups/${id}/drive`, { data })
36
-    var messages = response.data
37
-    onSuccess(formatState(messages))
38
-  } catch (error) {
39
-    var errors = response.errors
40
-    return onError(response.errors.map((err) => err.msg))
41
-  }
42
-}
43
-
44
-function formatState (messages) {
45
-  return messages.map(msg => JSON.stringify(msg, null, 2))
46
-}

+ 0
- 70
cobox-cli/bin/groups/join.js View File

@@ -1,70 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'join'
13
-exports.desc = 'join a group'
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address of the group',
17
-    type: 'string',
18
-    alias: 'A',
19
-  },
20
-  name: {
21
-    description: 'the name of the group',
22
-    type: 'string',
23
-    alias: 'n',
24
-    demandOption: true
25
-  }
26
-}
27
-exports.handler = async function (argv) {
28
-  let address = argv.address,
29
-    name = argv.name,
30
-    id = argv.address || argv.name,
31
-    response,
32
-    group
33
-
34
-  var data = { name, address }
35
-
36
-  try {
37
-    response = await request.get(`/groups/${id}`, { data })
38
-    group = response.data
39
-  } catch (error) {
40
-    response = error.response
41
-    var errors = response.data.errors
42
-    onError(errors.map((err) => err.msg))
43
-  }
44
-
45
-  if (!group && !address) return onError([`group does not exist, provide an address.`])
46
-
47
-  if (!group) {
48
-    onSuccess('creating a new group...')
49
-    try {
50
-      response = await request.post(`/groups`, data)
51
-      group = response.data
52
-    } catch (error) {
53
-      response = error.response
54
-      var errors = response.data.errors
55
-      return onError(errors.map((err) => err.msg))
56
-    }
57
-  }
58
-
59
-  try {
60
-    response = await request.post(`/groups/${group.address}/connections`, group)
61
-  } catch (error) {
62
-    response = error.response
63
-    var errors = response.data.errors
64
-    return onError(errors.map((err) => err.msg))
65
-  }
66
-
67
-  onSuccess(`successfully joined ${name}`)
68
-  onSuccess(`swarming on ${group.discoveryKey}`)
69
-  printGroups(group)
70
-}

+ 0
- 58
cobox-cli/bin/groups/leave.js View File

@@ -1,58 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'leave'
13
-exports.desc = 'drop open connections with remote peers'
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address of the group',
17
-    type: 'string',
18
-    alias: 'A',
19
-  },
20
-  name: {
21
-    description: 'the name of the group',
22
-    type: 'string',
23
-    alias: 'n',
24
-    demandOption: true
25
-  }
26
-}
27
-exports.handler = async function (argv) {
28
-  var id = argv.address || argv.name
29
-  if (!id) return onError('provide a name or address')
30
-
31
-  var response, group
32
-
33
-  var data = {
34
-    name: argv.name,
35
-    address: argv.address
36
-  }
37
-
38
-  try {
39
-    response = await request.get(`/groups/${id}`, { data })
40
-  } catch (error) {
41
-    response = error.response
42
-    var errors = response.data.errors
43
-    return onError(errors.map((err) => err.msg))
44
-  }
45
-
46
-  group = response.data
47
-
48
-  try {
49
-    response = await request.delete(`/groups/${id}/connections`, { data: group })
50
-  } catch (error) {
51
-    response = error.response
52
-    var errors = response.data.errors
53
-    return onError(errors.map((err) => err.message))
54
-  }
55
-
56
-  onSuccess(`connection for ${group.name} dropped.`)
57
-  printGroups(group)
58
-}

+ 0
- 23
cobox-cli/bin/groups/list.js View File

@@ -1,23 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'list'
13
-exports.desc = 'list all groups'
14
-exports.builder = {}
15
-exports.handler = async function (argv) {
16
-  try {
17
-    var response = await request.get('/groups')
18
-    return printGroups(response.data)
19
-  } catch (err) {
20
-    var errors = response.errors
21
-    return onError(errors.map((err) => err.msg))
22
-  }
23
-}

+ 0
- 51
cobox-cli/bin/groups/mount.js View File

@@ -1,51 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'mount'
13
-exports.desc = "mount a group"
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address for the group',
17
-    type: 'string',
18
-    alias: 'A',
19
-  },
20
-  name: {
21
-    description: 'the name of the group',
22
-    type: 'string',
23
-    alias: 'n',
24
-    demandOption: true
25
-  }
26
-}
27
-exports.handler = async function (argv) {
28
-  var id = argv.address || argv.name
29
-  if (!id) return onError('provide a name or address')
30
-
31
-  var data = { name: argv.name, address: argv.address }
32
-
33
-  try {
34
-    var response = await request.get(`/groups/${id}`, { data })
35
-  } catch (error) {
36
-    var errors = response.errors
37
-    return onError(errors.map((err) => err.msg))
38
-  }
39
-
40
-  var group = response.data
41
-
42
-  try {
43
-    var response = await request.post(`/groups/${group.address}/mounts`, group)
44
-  } catch (error) {
45
-    var errors = response.errors
46
-    return onError(errors.map((err) => err.msg))
47
-  }
48
-
49
-  onSuccess(`Mounted ${group.name} at ${response.data.location}.`)
50
-  printGroups(group)
51
-}

+ 0
- 50
cobox-cli/bin/groups/unmount.js View File

@@ -1,50 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'unmount'
13
-exports.desc = "unmount a group"
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address of the group',
17
-    type: 'string',
18
-    alias: 'A',
19
-  },
20
-  name: {
21
-    description: 'the name of the group',
22
-    type: 'string',
23
-    alias: 'n',
24
-    demandOption: true
25
-  }
26
-}
27
-exports.handler = async function (argv) {
28
-  var id = argv.address || argv.name
29
-  if (!id) return onError('provide a name or address')
30
-
31
-  var data = { name: argv.name, address: argv.address }
32
-
33
-  try {
34
-    var response = await request.get(`/groups/${id}`, { data })
35
-  } catch (err) {
36
-    var errors = response.errors
37
-    return onError(errors.map((err) => err.msg))
38
-  }
39
-
40
-  var group = response.data
41
-
42
-  try {
43
-    var response = await request.delete(`/groups/${id}/mounts`, { data: group })
44
-  } catch (error) {
45
-    var errors = response.errors
46
-    return onError(errors.map((err) => err.msg))
47
-  }
48
-
49
-  onSuccess(`Unmounted ${group.name || group.address}.`)
50
-}

+ 0
- 9
cobox-cli/bin/replicators.js View File

@@ -1,9 +0,0 @@
1
-exports.command = 'replicators'
2
-exports.desc = 'create, join, leave'
3
-exports.builder = function (yargs) {
4
-  return yargs.commandDir('replicators')
5
-    .demandCommand()
6
-    .help()
7
-    .argv
8
-}
9
-exports.handler = function (argv) {}

+ 0
- 70
cobox-cli/bin/replicators/join.js View File

@@ -1,70 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'join'
13
-exports.desc = 'join on an address as a blind replicator'
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address of the replicator',
17
-    type: 'string',
18
-    alias: 'A'
19
-  },
20
-  name: {
21
-    description: 'your local reference for the replicator',
22
-    type: 'string',
23
-    alias: 'n',
24
-    demandOption: true
25
-  }
26
-}
27
-exports.handler = async function (argv) {
28
-  let address = argv.address,
29
-    name = argv.name,
30
-    id = argv.address,
31
-    response,
32
-    replicator
33
-
34
-  var data = { name, address }
35
-
36
-  try {
37
-    response = await request.get(`/replicators/${id}`, { data })
38
-    replicator = response.data
39
-  } catch (error) {
40
-    response = error.response
41
-    var errors = response.data.errors
42
-    onError(errors.map((err) => err.msg))
43
-  }
44
-
45
-  if (!replicator && !address) return onError([`replicator does not exist, provide an address to replicate.`])
46
-
47
-  if (!replicator) {
48
-    onSuccess('creating a new replicator...')
49
-    try {
50
-      response = await request.post(`/replicators`, data)
51
-      replicator = response.data
52
-    } catch (error) {
53
-      response = error.response
54
-      var errors = response.data.errors
55
-      return onError(errors.map((err) => err.msg))
56
-    }
57
-  }
58
-
59
-  try {
60
-    response = await request.post(`/replicators/${replicator.address}/connections`, replicator)
61
-  } catch (error) {
62
-    response = error.response
63
-    var errors = response.data.errors
64
-    return onError(errors.map((err) => err.msg))
65
-  }
66
-
67
-  onSuccess(`successfully joined ${name}`)
68
-  onSuccess(`swarming on ${replicator.discoveryKey}`)
69
-  printGroups(replicator)
70
-}

+ 0
- 57
cobox-cli/bin/replicators/leave.js View File

@@ -1,57 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onSuccess,
6
-  onError,
7
-  printGroups
8
-} = require('../../util')
9
-
10
-const request = require('../../request')
11
-
12
-exports.command = 'leave'
13
-exports.desc = 'drop open connections with remote peers'
14
-exports.builder = {
15
-  address: {
16
-    description: 'the address of the replicator',
17
-    type: 'string',
18
-    alias: 'A'
19
-  },
20
-  name: {
21
-    description: 'your local reference for the replicator',
22
-    type: 'string',
23
-    alias: 'n'
24
-  }
25
-}
26
-exports.handler = async function (argv) {
27
-  var id = argv.address || argv.name
28
-  if (!id) return onError('provide a name or address')
29
-
30
-  var response, replicator
31
-
32
-  var data = {
33
-    name: argv.name,
34
-    address: argv.address
35
-  }
36
-
37
-  try {
38
-    response = await request.get(`/replicators/${id}`, { data })
39
-  } catch (error) {
40
-    response = error.response
41
-    var errors = response.data.errors
42
-    return onError(errors.map((err) => err.msg))
43
-  }
44
-
45
-  replicator = response.data
46
-
47
-  try {
48
-    response = await request.delete(`/replicators/${id}/connections`, { data: replicator })
49
-  } catch (error) {
50
-    response = error.response
51
-    var errors = response.data.errors
52
-    return onError(errors.map((err) => err.message))
53
-  }
54
-
55
-  onSuccess(`connection for ${replicator.name} dropped.`)
56
-  printGroups(replicator)
57
-}

+ 0
- 22
cobox-cli/bin/replicators/list.js View File

@@ -1,22 +0,0 @@
1
-const chalk = require('chalk')
2
-const path = require('path')
3
-
4
-const {
5
-  onError,
6
-  printGroups
7
-} = require('../../util')
8
-
9
-const request = require('../../request')
10
-
11
-exports.command = 'list'
12
-exports.desc = 'list all local blind replicators'
13
-exports.builder = {}
14
-exports.handler = async function (argv) {
15
-  try {
16
-    var response = await request.get('/replicators')
17
-    if (response.errors) return onError(errors.map((err) => err.msg))
18
-    return printGroups(response.data)
19
-  } catch (err) {
20
-    return onError(err.msg)
21
-  }
22
-}

+ 0
- 39
cobox-cli/bin/start.js View File

@@ -1,39 +0,0 @@
1
-const Config = require('cobox-config')
2
-const constants = require('cobox-constants')
3
-
4
-const App = require('cobox-server')
5
-const Server = require('cobox-server/server')
6
-
7
-exports.command = 'start'
8
-exports.desc = 'Start the server'
9
-exports.builder = {
10
-  storage: {
11
-    description: 'The storage path of your cobox configuration and cores',
12
-    type: 'string',
13
-    alias: 's',
14
-  },
15
-  mountdir: {
16
-    description: 'The root mount path for your groups',
17
-    type: 'string',
18
-    alias: 'm',
19
-  },
20
-  port: {
21
-    description: 'The server port for the application',
22
-    type: 'string',
23
-    alias: 'p',
24
-  },
25
-  host: {
26
-    description: 'The server host',
27
-    type: 'string',
28
-    alias: 'h',
29
-  }
30
-}
31
-exports.handler = function (argv) {
32
-  const storage = argv.storage || constants.storage
33
-  const config = Config(storage)
34
-  const location = argv.mountdir || config.options.get('mount') || constants.mountdir
35
-
36
-  const opts = { location, ...argv }
37
-  const app = App(config, opts)
38
-  Server(app, opts)
39
-}

+ 0
- 8
cobox-cli/cli.js View File

@@ -1,8 +0,0 @@
1
-#!/usr/bin/env node
2
-const yargs = require('yargs')
3
-const path = require('path')
4
-
5
-yargs.commandDir('bin')
6
-  .demandCommand()
7
-  .help()
8
-  .argv

+ 0
- 32
cobox-cli/package.json View File

@@ -1,32 +0,0 @@
1
-{
2
-  "name": "cobox-cli",
3
-  "description": "a command line client for cobox",
4
-  "version": "1.0.0",
5
-  "bin": {
6
-    "cobox": "cli.js"
7
-  },
8
-  "scripts": {
9
-    "test": "tape test/**/*.test.js | tap-spec"
10
-  },
11
-  "author": "magma-collective",
12
-  "license": "AGPL-3.0-only",
13
-  "dependencies": {
14
-    "axios": "^0.19.0",
15
-    "chalk": "^3.0.0",
16
-    "cobox-config": "git+https://ledger-git.dyne.org/cobox/cobox-config#development",
17
-    "cobox-constants": "^1.0.0",
18
-    "cobox-server": "git+https://ledger-git.dyne.org/cobox/cobox-server#development",
19
-    "debug": "^4.1.1",
20
-    "yargs": "^14.2.0"
21
-  },
22
-  "devDependencies": {
23
-    "rimraf": "^3.0.0",
24
-    "tap-spec": "^5.0.0",
25
-    "tape": "^4.11.0",
26
-    "tape-plus": "^1.0.0",
27
-    "tmp": "^0.1.0"
28
-  },
29
-  "bugs": {
30
-    "url": "https://ledger-git.dyne.org/CoBox/cobox-cli"
31
-  }
32
-}

+ 0
- 7
cobox-cli/request.js View File

@@ -1,7 +0,0 @@
1
-const axios = require('axios')
2
-
3
-module.exports = axios.create({
4
-  baseURL: 'http://localhost:3000/',
5
-  timeout: 5000,
6
-  headers: { 'Content-type': 'application/json' }
7
-})

+ 0
- 54
cobox-cli/util.js View File

@@ -1,54 +0,0 @@
1
-const chalk = require('chalk')
2
-const readline = require('readline')
3
-
4
-function printGroups (groups) {
5
-  groups = Array.isArray(groups) ? groups : [groups]
6
-  console.log("-- Name --".padEnd(40), "-- Address --".padEnd(64))
7
-  for (const group of groups) {
8
-    const name = group.name || ''
9
-    console.log(
10
-      name.padEnd(40),
11
-      chalk.green(group.address),
12
-    )
13
-  }
14
-  console.log()
15
-}
16
-
17
-function getInput (message, cb) {
18
-  const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
19
-  rl.question(message, (answer) => {
20
-    if (!answer) return getInput(message, cb)
21
-    cb(answer)
22
-    rl.close()
23
-  })
24
-}
25
-
26
-function onSuccess (msgs) {
27
-  msgs = Array.isArray(msgs) ? msgs : [msgs]
28
-  for (const msg of msgs) console.log(msg, '\n')
29
-}
30
-
31
-function onError (errs) {
32
-  errs = Array.isArray(errs) ? errs : [errs]
33
-  for (const err of errs) console.error(chalk.red(err), '\n')
34
-}
35
-
36
-function getName (name) {
37
-  var prompt = 'provide a name for your group...\n'
38
-  return new Promise((resolve, reject) => {
39
-    return next(null, name)
40
-
41
-    function next (err, name) {
42
-      if (err) return reject(err)
43
-      if (!name) getInput(prompt, next)
44
-      else return resolve(name)
45
-    }
46
-  })
47
-}
48
-
49
-module.exports = {
50
-  getInput,
51
-  printGroups,
52
-  onSuccess,
53
-  onError
54
-}

+ 1
- 1
cobox-config

@@ -1 +1 @@
1
-Subproject commit 50bfef2e872413b0d38176db386f77aee67328aa
1
+Subproject commit af715a3d605048ebad28a98677c3bdd3a223ddee

+ 1
- 1
cobox-crypto

@@ -1 +1 @@
1
-Subproject commit 8c99f3f8cb6bba4a218e1f394d263290d4130284
1
+Subproject commit 1fe539f66bebafe0e5b78d6a10430ec91f7fca98

+ 1
- 1
cobox-group

@@ -1 +1 @@
1
-Subproject commit 33069e72980132dad19aaca33a3ae8acb48d0611
1
+Subproject commit 3db5a35ae0a9ba0e8dd63e15b8aac556d7016b17

+ 1
- 1
cobox-group-store

@@ -1 +1 @@
1
-Subproject commit 28a2a2ad34aeeef5b31fcdda539374220b24be2e
1
+Subproject commit 4803a60ec2b6b6c18751d33fae03147d7a399f71

+ 1
- 1
cobox-server

@@ -1 +1 @@
1
-Subproject commit b4245713073310b547fb9c93d3c81b61e2ec0e9a
1
+Subproject commit beb459ad40b2fba44ac603619706dfaed586ce72

+ 1
- 1
cobox-swarm

@@ -1 +1 @@
1
-Subproject commit cf71f7f2e3207e3d4b50e3403b192e8870d1c026
1
+Subproject commit 28ef495ab9afccb9cb7c43e6150a57d76f0dde31

+ 1
- 1
kappa-drive

@@ -1 +1 @@
1
-Subproject commit bcb3a48bd3fe8dda4969b86d65a5075b3e8f2281
1
+Subproject commit 104c5548ee6912fda789e95573f4046a1a2e34ce

+ 1
- 1
kappa-drive-mount

@@ -1 +1 @@
1
-Subproject commit 18d2635f7e9b64d0454ede2c6cedb679f7281aee
1
+Subproject commit a81abfe07830fb60eaea5ab6e8d39846e537efbc

+ 1
- 1
kappa-view-query

@@ -1 +1 @@
1
-Subproject commit 25fa130060c610ac66e374f3573c90995c763f8d
1
+Subproject commit 4e82f22ab4bc298583e45f4a1801e7e3a602d8ab